我有一個在列出對應於信貸員數字的表名prequals_created
命名loanofficer
列。我想更新此列有信貸員名稱,而不是數量,它位於一個名爲appusers
表,其中fullname
與loanofficer
ID匹配。我試圖這樣做,首先使用SELECT通過使用名爲loan_pairing
的「中間」表來生成信貸員名稱和id作爲一對錶。然而,我的語法有些問題。這裏是我的代碼:UPDATE SQL柱選擇值
UPDATE
prequals_created AS pc
SET
pc.loanofficer = lonames.fullname
FROM
(SELECT DISTINCT a.fullname, lp.loanofficer
FROM appusers AS a
JOIN loan_pairing AS lp
ON a.id = lp.loanofficer
JOIN prequals_created AS pc
ON lp.loanofficer = pc.loanofficer) AS lonames
WHERE
pc.loanofficer = lonames.loanofficer
嵌套在FROM語句中的SELECT語句是正確的,並返回各自的ID成對信貸員的姓名。
這裏關於我的語法到底是什麼?
是位於您的全名列在用戶? –
是的,它是(額外字符) – Jodo1992
我覺得loan_pairing表亙古不抱什麼特別做這個工作,即APPUSER的id是prequals_created表作爲loanofficer,你想用全名是在appsuser表 –