table A
FileId FileName
1 1.txt
2 2.txttable B
DirId DirName DirAttribute
1 C:\ 0
2 D:\ 1
3 E:\ 2
4 F:\ 3table C
Id DirId FileId
1 1 1
2 1 2
3 2 1
4 2 2
5 3 1
6 4 2如何用一条语句查找出表C中与DirId为1的FileId相同的所有DirId?
FileId FileName
1 1.txt
2 2.txttable B
DirId DirName DirAttribute
1 C:\ 0
2 D:\ 1
3 E:\ 2
4 F:\ 3table C
Id DirId FileId
1 1 1
2 1 2
3 2 1
4 2 2
5 3 1
6 4 2如何用一条语句查找出表C中与DirId为1的FileId相同的所有DirId?
select DirId from C a where DirId in(select FileId from C where DirId=1);
from C
group by DirId
having group_concat(FileId ORDER BY FileId) = (select group_concat(FileId ORDER BY FileId) from C where DirId=1)