当前位置: 代码迷 >> Sql Server >> 折磨了很久的sql语句
  详细解决方案

折磨了很久的sql语句

热度:34   发布时间:2016-04-24 09:19:00.0
折磨了很久的sql语句,求救
求一条sql语句,gc表字段有gh,uploadflag,img表字段有gh,tagid,uploadflag,pic表字段有gh,tagid,uploadflag.
现在需要查询出来gc表中uploadflag=0并且img的tagid=0,uploadflag=1和tagid=1,uploadflag=1,表pic的tagid=1,uploadflag=1,
换个说法就是查询出gc表中uploadflag=0并且满足有3张照片已经上传的gh,
img表和pic表分别表示不同阶段的图片,tagid为0到9表示不同的流程,
不能用存储过程实现,因为数据库操作类不支执存储过程
------解决思路----------------------
不知道理解的对不对
select * from gc where uploadflag=0 
and exists (select * from img where gh=gc.gh and uploadflag=1 and (tagid=0  or tagid=1))
and exists (select * from pic where gh=gc.gh and tagid=1 and uploadflag=1)
  相关解决方案