簡體   English   中英

在匹配兩個表中的電子郵件時,從另一個表中插入列

[英]Insert column from another table while matching emails in both tables

我正在嘗試將訂單表中的電話號碼字段插入到用戶表中,同時匹配訂單。電子郵件字段= users.Email字段。

到目前為止,這是我所需要的,但是WHERE子句不起作用:

INSERT INTO users (Phone)  
SELECT Billing_Phone
  FROM orders
WHERE users.Email = orders.Email

要修改行,請使用UPDATE而不是INSERT

UPDATE users AS u
JOIN orders AS o ON u.Email = o.Email
SET u.Phone = o.Billing_Phone

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM