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

sql多表联合查询
这句查询语句要怎么改
SQL code

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'



------解决方案--------------------
C# code
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'

------解决方案--------------------
SQL code

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