我是 MYSQL 查询新手。我在同一个数据库中有两个不同的表。每个表只有 3 列。我想与第一个表中的第二个表进行比较。
表1:
path -> C:/sume/sorve/data001/data001.jpg
frn -> 256423
byte -> 153
table 2:
path -> C:/ones/elsa/data001/data001.jpg
frn -> 256423
byte -> 153
我需要匹配 (data001/data001.jpg, 256423, 153),我该怎么做?因为之前的一些data001子目录总是来自不同的目录。
哪些记录与第二个表不匹配,我需要该记录..
最佳答案
用这个试试
select t1.* from table1 t1
left join table2 t2 on
substring_index(t2.path, '/', -1) = substring_index(t1.path, '/', -1)
and t2.frn = t1.frn
and t2.byte = t1.byte
where t2.path is null or t2.frn is null or t2.byte is null
编辑路径。现在检查它是否应该工作
关于mysql - 如何比较mysql中同一数据库中的两个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16728657/