【发布时间】:2010-12-11 08:43:24
【问题描述】:
作为 Postgresql 的新手(我要搬家是因为我要将我的网站转移到仅支持它的 heroku,我不得不重构我的一些查询和代码。这是一个我不太能解决的问题理解问题:
PGError: ERROR: column "l_user_id" does not exist
LINE 1: ...t_id where l.user_id = 8 order by l2.geopoint_id, l_user_id ...
^
...查询:
select distinct
l2.*,
l.user_id as l_user_id,
l.geopoint_id as l_geopoint_id
from locations l
left join locations l2 on l.geopoint_id = l2.geopoint_id
where l.user_id = 8
order by l2.geopoint_id, l_user_id = l2.user_id desc
添加了子句“l.user_id as l_user_id, l.geopoint_id as l_geopoint_id”,因为显然 postgres 不喜欢未选择字段的 order 子句。但是我现在得到的错误使它看起来我也没有得到别名。有 postgres 经验的人看到这个问题吗?
我可能会遇到很多这样的问题——查询在 mySql 中运行良好...
【问题讨论】:
-
越容易阅读,我们就越容易为您提供帮助...
标签: sql mysql postgresql alias heroku