最顶上结果为什么多查询出一条?
select1asflag,bh,gm,wjm,yz,gx,bbfromt1wherenotexists(select1fromt2wheret1.bc=t2.bcand...
select 1 as flag,bh,gm,wjm,yz,gx,bb from t1 where not exists (select 1
from t2 where t1.bc=t2.bc and
t1.yc=t2.yc and
t1.gm=t2.gm and
t1.yz=t2.yz and
t1.gx=t2.gx and
t1.zt=t2.zt and
t1.bb=t2.bb and
t1.wjm=t2.wjm and
t1.xg=t2.xg)
union all
select 0 as flag,bh,gm,wjm,yz,gx,bb from t2 where not exists(select 1
from t1 where t1.bc=t2.bc and
t1.yc=t2.yc and
t1.gm=t2.gm and
t1.yz=t2.yz and
t1.gx=t2.gx and
t1.zt=t2.zt and
t1.bb=t2.bb and
t1.wjm=t2.wjm and
t1.xg=t2.xg)
xg是时间类型!!!!!!!!!!!!!!!!!!! 展开
from t2 where t1.bc=t2.bc and
t1.yc=t2.yc and
t1.gm=t2.gm and
t1.yz=t2.yz and
t1.gx=t2.gx and
t1.zt=t2.zt and
t1.bb=t2.bb and
t1.wjm=t2.wjm and
t1.xg=t2.xg)
union all
select 0 as flag,bh,gm,wjm,yz,gx,bb from t2 where not exists(select 1
from t1 where t1.bc=t2.bc and
t1.yc=t2.yc and
t1.gm=t2.gm and
t1.yz=t2.yz and
t1.gx=t2.gx and
t1.zt=t2.zt and
t1.bb=t2.bb and
t1.wjm=t2.wjm and
t1.xg=t2.xg)
xg是时间类型!!!!!!!!!!!!!!!!!!! 展开
1个回答
2013-09-17
展开全部
你是说“阿杜” 那条吗?如果是的话,那是因为你用union all导致的!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询