查询2张表里的数据
select a.executedate,a.shopid,s.shopname,a.venderid,v.vendername,a.sheetid,a.goodsid,b.goodslname,a.logistics, c.majorid,c.majorname,c.medcategoryid,c.medcategoryname,c.categoryid,c.categoryname,d.brandname,recqty,retqty,(recqty-retqty)qty, rev,norev,a.rtv,a.nortv,(rev-rtv)rv,(norev-nortv)norv from temp_mx a,goods b,v_alldept c,shop s,vender v,brand d where a.goodsid=b.goodsid and b.categoryid=c.categoryid and a.shopid=s.shopid and a.venderid=v.venderid and b.brandid=d.brandid
我老是写不清楚这些条件,如果不写这些条件查出来出具很多,我想了解下 加了这些条件有什么用处
[解决办法]
表之间的连接。
from temp_mx a,goods b,v_alldept c,shop s,vender v,brand d
where a.goodsid=b.goodsid
and b.categoryid=c.categoryid
and a.shopid=s.shopid
and a.venderid=v.venderid
and b.brandid=d.brandid
[解决办法]
实际上就是内连接
INNER JOIN goods b ON a.goodsid=b.goodsid
INNER JOIN ....