本文介紹了從另一個(gè)表更新一個(gè)字段的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我需要從另一個(gè)表的字段更新一個(gè)表的字段.我遵循了完全相同的鏈接 Stackoverflow 但我遇到了語(yǔ)法錯(cuò)誤.
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 之前放置一個(gè)內(nèi)部聯(lián)接.如果我正確理解你的架構(gòu),這樣的事情應(yīng)該可以工作:
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 = ''
這篇關(guān)于從另一個(gè)表更新一個(gè)字段的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!