带有嵌套Query的SQL Update表

时间:2018-04-06 12:47:00

标签: sql sql-server

我遇到了这个问题的问题。我有错误:

标识符无效

我想从嵌套查询中使用MSISDN更新表MAIN中的colum CONTACT,其中MAIN中的N_ACCOUNT与嵌套查询中的ACCOUNT匹配

UPDATE MAIN

SET CONTACT = BASE.MSISDN

WHERE N_ACCOUNT IN 

                (
                   SELECT BASE.MSISDN, BASE.ACCOUNT

                    FROM (

                         SELECT  TBL1 AS MSISDN, TBL2 AS ACCOUNT

                         FROM    TBL3,
                                 TBL2,
                                 TBL1

                         WHERE   TBL2.DW_SUPP_SERV_ID=TBL3.DW_PRICEBL_ID
                             AND TBL3.DW_ORIG_SERV_ID = TBL1.DW_ORIG_SERV_ID
                             AND TBL2.SUPP_SERV_CODE IN 
                                    ('DAY37','DAYAP','DAYQA','DBY4G')
                             AND TBL3.DW_SUPP_SERV_ST_ID='100000001'


                         )BASE

                WHERE BASE.ACCOUNT=MAIN.N_ACCOUNT


              );

0 个答案:

没有答案