表中CUSTOMERS
的值由唯一ID
值识别,此表中的所有记录也都有CONSENT
布尔属性。
我需要将CONSENT
值复制到CONSENT2
布尔字段以获取相同的记录。
据我所知,此服务器上禁用了几个SQL命令。
这会有用吗?
UPDATE
CUSTOMERS
SET
CUSTOMERS_A.CONSENT_Email = CUSTOMERS_A.CONSENT_Email2
CUSTOMERS_A.CONSENT_Phone = CUSTOMERS_A.CONSENT_Phone2
FROM
CUSTOMERS AS CUSTOMERS_A
INNER JOIN CUSTOMERS AS CUSTOMERS_B
ON CUSTOMERS_A.id = CUSTOMERS_B.id
答案 0 :(得分:1)
你可以不加入
UPDATE
CUSTOMERS
SET CONSENT_Email = CONSENT_Email2,
CONSENT_Phone = CONSENT_Phone2
答案 1 :(得分:1)
您可以简单地使用,在真正需要之前不要添加额外的连接/条件。
UPDATE CUSTOMERS
SET (CONSENT_Email2,CONSENT_Phone2) = (CONSENT_Email,CONSENT_Phone);
它会将两列的CONSENT2值复制到CONSENT中。
i.e. CONSENT >>> CONSENT2