日期:2014-05-17  浏览次数:20592 次

sql多表联合查询

select 
Goods.* from Goods 
inner join GoodsPreviewPic.* from GoodsPreviewPic 
on Goods.goodsNum=GoodsPreviewPic.goodsNum 
inner join GoodsModelPic.* 
from GoodsModelPic on Goods.goodsNum=GoodsModelPic.goodsNum 
where Goods.goodsNum='100001'


消息 102,级别 15,状态 1,第 2 行
'Goods' 附近有语法错误。

该怎么改啊
------解决方案--------------------
select 
    Goods.* from Goods 
    inner join GoodsPreviewPic on Goods.goodsNum=GoodsPreviewPic.goodsNum 
    inner join GoodsModelPic on Goods.goodsNum=GoodsModelPic.goodsNum 
    where Goods.goodsNum='100001'
------解决方案--------------------
select 
     Goods.* from Goods 
     inner join (select  GoodsPreviewPic.* from GoodsPreviewPic )GoodsPreviewPic 
     on Goods.goodsNum=GoodsPreviewPic.goodsNum 
     inner join (select  GoodsModelPic.* 
     from GoodsModelPic)GoodsModelPic on Goods.goodsNum=GoodsModelPic.goodsNum 
     where Goods.goodsNum='100001'