I may be missing something because I thought this would be a simple task.
I wanted to retrieve results that were not included in Table 3.
Any help?
Table 1
T1C1 T1C2
1 London
2 New York
3 Paris
4 Cardiff
5 Bradford
6 Sydney
7 Bradford
8 Beijing
9 Cairo
Table 2
T2C1 T2C2
A UK
Table 3
T3C1 T3C2
1 A
4 A
5 A
7 A
Result
T1C1 T1C2
2 New York
3 Paris
6 Sydney
8 Beijing
9 Cairo
select * from Table1 where T1C1 not in (select T3C1 from Table3)
select * from Table1 left join Table2 on T1C1=T3C1 where T3C2 IS NULL
select * from Table1 where not exists (select 1 from Table2 where T1C1=T3C1)
(由Tim Schmelter在评论中建议) You could just use NOT IN;
SELECT * FROM Table1 WHERE T1C1 NOT IN (
SELECT T1C1 FROM Table3
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.