这条SQL语句如何写?
一个商品库存表
商品码itemid 库存数量stockqty
一个销售日结表
商品码itemid 销售数量qty
要查出有库存但是没有销量的商品信息
商品若是没有销售的话 不会存在销售日结表
[解决办法]
你select * 或者字段 也是一样的 select * from t1 where t1.stockqty>0 and not exists(select 1 from t2 where t1.itemid=t2.itemid)
新手 有点不太明白
能否解释下为什么子查询里 要select 1
那么子查询的条件就是关联字段么?