+ -
当前位置:首页 → 问答吧 → 多表对比

多表对比

时间:2011-11-06

来源:互联网

table1:

 id date cre
 1 12 a
 2 13 b

table2:

 id lot len
 1 a01 1
 2 a02 2
 3 a04 2

根据量表对比查询table2 中有的ID值在table1 中没有
id lot len
 3 a04 2

作者: answer_0725   发布时间: 2011-11-06

没看懂

作者: liuxianfang11   发布时间: 2011-11-06

根据两表对比查询table2 表 中有的ID值在table1 中没有
两表关联的值 就 ID

作者: answer_0725   发布时间: 2011-11-06

SQL code
SELECT * FROM table2 WHERE id NOT IN(SELECT id FROM table1)

作者: Leftie   发布时间: 2011-11-06

SQL code
select * from table2 t where not exists(select 1 from tbale1 where id=t.id)

作者: fredrickhu   发布时间: 2011-11-06