我尝试将订单表中的电话号码字段插入到用户表中,同时匹配orders.Email字段= users.Email字段。
这是我到目前为止,但WHERE
子句不起作用:
INSERT INTO users (Phone)
SELECT Billing_Phone
FROM orders
WHERE users.Email = orders.Email
答案 0 :(得分:1)
要修改行,请使用UPDATE
,而不是INSERT
。
UPDATE users AS u
JOIN orders AS o ON u.Email = o.Email
SET u.Phone = o.Billing_Phone