想要将一列数据复制到 SQL 中的另一列 table 中...使用此查询不起作用

Want to copy one column data into anothers table column in SQL...using this query its not working

UPDATE temp_test
 SET country_i = (select a.country_code from temp_test2 a,temp_test c
                       where c.country_i is null and 
            a.active = 'A' and c.created_by = a.partner_by)

您可以使用 MERGE 语句。很容易理解。

MERGE INTO temp_test t
USING temp_test2 u
ON (t.created_by = u.partner_by)
WHEN MATCHED THEN 
UPDATE SET
   t.country_i = u.country_code
   WHERE t.country_i IS NULL
   AND   u.active = 'A';
UPDATE temp_test c SET country_i = (select a.country_code from temp_test2 a where a.active = 'A' and c.created_by = a.partner_by) where c.country_i is null;

在我看来它应该有效...