求教SQL语句
exists (select 1 from Sto_GoodsConsign where ConsignID=sto_consigninfo.ConsignID and weight is not null)
借用别人的例子说明一下,EXISTS判断某个操作是否有结果。
EXISTS 和in类似,但效率要比in高
SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND EXISTS (SELECT ‘X' FROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO AND LOC = ‘MELB')
SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND DEPTNO IN(SELECT DEPTNO FROM DEPT WHERE LOC = ‘MELB')
用起来,in还是要直观一些。
你参照以上例子,相信可以构建自己的查询的。