有两张表 A,B,都有字段 id, 查询A表中所有的 A.id 在 B表中也存在的记录
select * from A where id in (select id from B where id in (select id from A))
或者
select Aid from (
select A.id as Aid,B.id as Bid from A left join B on A.id=B.id
) as tmp where Bid is not null
这样查询试一下看对不对吧
select
from a t0 ,b t1
where t0.id=t1.id
select distinct a.id from A a,B b where a.id=b.id