本文介紹了從另一個表更新一個字段的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我需要從另一個表的字段更新一個表的字段.我遵循了完全相同的鏈接 Stackoverflow 但我遇到了語法錯誤.
I need to update one table's fields from another table's fields. I followed exactly the same link Stackoverflow but I am getting a Syntax Error.
這是我的查詢
UPDATE crm_leads
SET landlord_name = crm_owners.name,
last_name = crm_owners.last_name
FROM crm_owners
WHERE crm_owners.id =crm_leads.landlord_id
AND crm_leads.landlord_name = ''
AND crm_leads.last_name = ''
推薦答案
嘗試在 UPDATE 之后但在 SET 之前放置一個內部聯接.如果我正確理解你的架構,這樣的事情應該可以工作:
Try placing an inner join after your UPDATE but before your SET. If I understand your schema correctly, something like this should work:
UPDATE crm_leads
INNER JOIN crm_owners
ON crm_owners.id = crm_leads.landlord_id
SET crm_leads.landlord_name = crm_owners.name,
crm_leads.last_name = crm_owners.last_name
WHERE crm_leads.landlord_name = ''
AND crm_leads.last_name = ''
這篇關于從另一個表更新一個字段的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!