left join 多个表关联时,将表值置换

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT 
      B.[GOODSID]
      ,A.INDUSTRY_CNAME
      ,C.[PRODUCTTYPE_NAME]
      ,'TMALL' AS "??"
      ,D.[BRAND_NAME]
      ,E.[PROVINCE_NAME]
      ,[SHOPNAME]
      ,F.CITY_NAME
      ,[TITLE]
      ,[PRICE]
      ,[DISCOUNT]
      ,[SALE_VOLUME]
      ,[SALE_AMOUNT]
      ,[COMMEN_NUM]
      ,[POSITIVE_COMMEN]
      ,[MODERATE_COMMEN]
      ,[NEGATIVE_COMMEN]
      ,[COLLECTION_NUM]
      ,[REPUTATION]
      ,[SHOPTYPE]
      ,[SHELVES_TIME]
      ,[YEAR]
      ,[MONTH]
      ,[DETAIL_URL]
  FROM [TM_DATA].[dbo].[SALEDETIL] B left join INDUSTRY A ON A.ID=B.INDUSTRY_ID
  LEFT JOIN PRODUCTTYPE C ON B.PRODUCTTYPE_ID=C.ID
  LEFT JOIN BRAND D ON B.BRAND_ID=D.ID
  LEFT JOIN PROVINCE E ON B.PROVINCE_ID=E.ID
  LEFT JOIN CITY F ON B.CITY_ID = F.ID

  
  where B.[MONTH]=7 AND B.PROVINCE_ID=16 AND B.PRODUCTTYPE_ID=28

 

posted @ 2017-01-05 16:28  _Nestling  阅读(5933)  评论(0编辑  收藏  举报