作者ogrechen (ogrechen)
看板Database
标题[SQL ] 找出两个 column 中的相异值
时间Fri Dec 1 16:47:03 2006
[资料库] Mysql 4.1
ex:
table1: table2:
c1 c2
------ ------
1 1
2 2
3 6
4
5
需要从 table1.c1 中, 找出 table1.c1 不等於 table2.c2 的数值
使得输出为: 3 4 5
有个方式为 select c1 from table1 where c1 not in ( select c2 from table2 );
不过这牵涉到两次 select
请问: 有别的方式可以达到相同的效果吗???
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.139.135.197
※ 编辑: ogrechen 来自: 220.139.135.197 (12/01 18:07)
1F:推 flakchen:不懂两次Select有啥不好?? 12/01 20:48
2F:推 Adonisy:两次 select不好? 12/02 14:11