我正在尝试使用第二个表中的内连接更新表中的两个字段,但仅限于第一个表中未填充其中一个字段的行(例如null)(如下所示)。这是我正在尝试使用的查询。
SET SQL_SAFE_UPDATES = 0;
UPDATE mydb.mbb_pla_inputs pl
INNER JOIN mydb.class_nm_lookup_table class ON pl.RMS_CLASS_NM = class.RMS_CLASS_NM
SET pl.campaign_name = class.campaign, pl.ad_group_name = class.ad_group
WHERE pl.campaign_name IS NULL;
SET SQL_SAFE_UPDATES = 1;
但是它似乎没有更新记录。任何人都可以帮助我吗?
mydb.mbb_pla_inputs
# idmbb_pla_inputs, insertion_timestamp, RMS_CLASS_NM, SKU_NUM, PRODUCT_GROUP, TRACKING_TEMPLATE, MAX_CPC, BID_DATE, campaign_name, ad_group_name
205607, 2018-04-30 08:23:59, Ab Rollers Core, 10166704, * / Item ID='10166704', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10166704, , 2017-01-01 00:00:00, ,
205608, 2018-04-30 08:23:59, Ab Rollers Core, 10195301, * / Item ID='10195301', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10195301, , 2017-01-01 00:00:00, ,
205609, 2018-04-30 08:23:59, Ab Rollers Core, 10195303, * / Item ID='10195303', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10195303, , 2017-01-01 00:00:00, ,
205610, 2018-04-30 08:23:59, Ab Rollers Core, 10261308, * / Item ID='10261308', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10261308, , 2017-01-01 00:00:00, ,
205611, 2018-04-30 08:23:59, Ab Rollers Core, 10261336, * / Item ID='10261336', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10261336, , 2017-01-01 00:00:00, ,
205612, 2018-04-30 08:23:59, Ab Rollers Core, 10266581, * / Item ID='10266581', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10266581, , 2017-01-01 00:00:00, ,
205613, 2018-04-30 08:23:59, Ab Rollers Core, 10266591, * / Item ID='10266591', {unescapedlpurl}&cmp=KNC-[*EngineAccountType*]:[*Campaign*]:[*Adgroup*]:10266591, , 2017-01-01 00:00:00, ,
mydb.campaigns
# idpla_campaigns, RMS_CLASS_NM, campaign, ad_group, insertion_timestamp
'1', 'RMS_CLASS_NM', 'CAMPAIGN', 'AD_GROUP', '2018-04-02 15:16:26'
'2', 'CARDIO EQUIPMENT', 'mvp_cardio', 'Cardio', '2018-04-02 15:16:26'
'3', 'BABY MONITORS', 'mvp_baby', 'Baby', '2018-04-02 15:16:26'
'4', 'CAR SEATS', 'mvp_baby', 'Baby', '2018-04-02 15:16:26'
'5', 'NURSERY & DECOR', 'mvp_baby', 'Baby', '2018-04-02 15:16:26'