1.mysql 查询一个表中没有存在在另一个表的数据
SELECT * FROM A
WHERE id NOT IN ( SELECT id FROM B);
或者
SELECT * FROM A
WHERE
NOT EXISTS (
SELECT 1
FROM B
WHERE B.id = A.id );
或者
SELECT
A.*
FROM
A LEFT JOIN B
ON (A.id = B.id)
WHERE
b.id IS NULL
2.Mysql中怎么筛选一个表之后然后再和另外一个表做表连接
例如A表有id,name,adress字段,B表有id,country,work字段,现在我想筛选表A中id大于10的列然后,筛选后的表和B表进行连接
select a.id , a.name ,a.adress,B.country from
( select * from A where id>10) a
join B on a.id=B.id
( select * from A where id>10) a
join B on a.id=B.id
3.mysql根据一个表的id删除另一个表的记录
delete from Awhere id in (select id from B)。