在SQL中加入3个表

时间:2015-09-30 12:32:23

标签: sql sql-server

我有这个代码组合2个表,我想从说vBoAdd C添加第三个。我需要在哪里添加其他INNER JOIN代码行?

Select A.ID, A.SUPPLIER_SPECIALTY, B.Code, B.Description,
    C.Address1 + ' ' + C.Address2 + ' '+ C.Address3 AS Address, C.Phone
     FROM vBoCsGeneralLookupTables B
    INNER JOIN (
             SELECT A.ID, 
             Split.a.value('.', 'VARCHAR(100)') AS SUPPLIER_SPECIALTY
             FROM 
             (
                 SELECT ID,
                     CAST ('<M>' + REPLACE(SUPPLIER_SPECIALTY, ',', '</M><M>') + '</M>' AS XML) AS SUPPLIER_SPECIALTY 
                 FROM  JOA_COMPANY_DEMO A
                 WHERE SUPPLIER_SPECIALTY != ''

             ) AS A CROSS APPLY SUPPLIER_SPECIALTY.nodes ('/M') AS Split(a)
    ) A
    ON A.SUPPLIER_SPECIALTY=B.Code
    WHERE B.TableName = 'SUPPLIER_SPECIALTY'

1 个答案:

答案 0 :(得分:0)

下一个INNER JOIN可以在您的WHERE子句之前,在ON INNER JOIN的{​​{1}}条款之后。