Sivo 悉见

mysql查询两个表中不匹配的数据

匿名 · 更新于 2013/12/27

有A表,A表字段如下
aID aName aAddTime
有B表,B表字段如下
bID bCon
其中B表中的bID为A表中aID的外键,同时是B表的主键
现在A表有20条数据,B表有16条数据,我想查询到A表中哪4条数据在B表中没有出现

select * from A where aID not in (select bID from B)
select * from tb_nav where navID not in (select contentID from tb_doccontent)