在Postgresql的where子句中使用Alias列我有這樣的查詢:SELECT
jobs.*,
(
CASE
WHEN lead_informations.state IS NOT NULL THEN lead_informations.state ELSE 'NEW'
END
) AS lead_stateFROM
jobs LEFT JOIN lead_informations ON
lead_informations.job_id = jobs.id AND
lead_informations.mechanic_id = 3WHERE
lead_state = 'NEW'這給出了以下錯誤:PGError: ERROR: column "lead_state" does not exist
LINE 1: ...s.id AND lead_informations.mechanic_id = 3 WHERE (lead_state...在MySql中這是有效的,但顯然不在Postgresql中。從我可以收集的內(nèi)容來看,原因是SELECT查詢的WHERE一部分晚于部分進行評估。這個問題有一個共同的解決方法嗎?
在Postgresql的where子句中使用Alias列
蝴蝶刀刀
2019-08-09 10:27:39