在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中。从我可以收集的内容来看,原因是SELECT查询的WHERE一部分晚于部分进行评估。这个问题有一个共同的解决方法吗?
添加回答
举报
0/150
提交
取消