table1:
id name
1 123
2 456
3 789
4 789
table2:
id name
1 345
2 789
3 456
4 976
result:
id name
1 456
2 789
谢谢了
------解决方案--------------------
2005以上用INTERSECT,用法和union一样,手机就不写了:
表一
INTERSECT
表二
2000的话用exists
------解决方案--------------------
如果还要关联,可以这样:
select *
from
(
select table1.name from table1
where exists (select table2.name from table2 where table1.name = table2.name)
)table1
left join t3 on left(table1.name,7)=t3.name