有一张表father
字段1
aa
bb
cc
...sonid 字段1 字段2
1 aa aa11
2 aa aa22
3 cc cc11
.. ... ... 我想查询子类中没有,父类含有子类为0的父类 字段1 怎么查询啊????
同志们帮我解决问题的时候顺便介绍些sql语句书我看看
我sql功底太差了
字段1
aa
bb
cc
...sonid 字段1 字段2
1 aa aa11
2 aa aa22
3 cc cc11
.. ... ... 我想查询子类中没有,父类含有子类为0的父类 字段1 怎么查询啊????
同志们帮我解决问题的时候顺便介绍些sql语句书我看看
我sql功底太差了
--
这样?
-- or
select * from father left join son on father.字段1=son.字段1
where son.字段1 is null
select * from father where 字段1 not in (select 字段1 from son)
--父类含有的但子类中无的记录
select * from father where 字段1 not in (select 字段1 from son)
--多看看MSDN.有问题就来CSDN....
--或者
select * from father left join son on father.字段1=son.字段1
where son.字段1 is null