求个郁闷的SQL语句各位大虾小弟
给LZ补充一种SQL查询方法,不使用表达式,但是有两个子查询,效率方面不好说。不过,可以使用上索引,应该会好一些吧。
仅供LZ参考:
select * from DA
where BH not in (select BH from XI) or XH not in (select XH from XI)
PS:
由于考虑不周,的确存在LZ所说的问题。 下面是改进后的SQL语句,避免了上面的问题,至于检索速度,就要看是否有索引及索引的效率了。
select * from DA where BH not in
( select DA。 BH from DA,XI
where DA。BH =...全部
给LZ补充一种SQL查询方法,不使用表达式,但是有两个子查询,效率方面不好说。不过,可以使用上索引,应该会好一些吧。
仅供LZ参考:
select * from DA
where BH not in (select BH from XI) or XH not in (select XH from XI)
PS:
由于考虑不周,的确存在LZ所说的问题。
下面是改进后的SQL语句,避免了上面的问题,至于检索速度,就要看是否有索引及索引的效率了。
select * from DA where BH not in
( select DA。
BH from DA,XI
where DA。BH = XI。BH AND DA。XH = XI。XH) OR XH not in
( select DA。XH from DA,XI
where DA。
BH = XI。BH AND DA。XH = XI。XH)
。收起