【发布时间】:2012-07-25 10:33:41
【问题描述】:
我想从 2 个表中选择,其中第二个 id 与第一个 id 的前 4 个字符相等
SELECT a.*, b.*, substring(a.my_id from 1 for 4)::integer as number
FROM table1 as a
INNER Join table2 as b ON(b.id_2=number) where my_id = 101
^
It produces an error here |
错误:“数字”列不存在
SQL 状态:42703
字符:189
【问题讨论】:
-
SELECT列表中的别名在FROM列表中不起作用。将substring(a.my_id from 1 for 4)::integer移动到您的ON条件。
标签: postgresql select substring inner-join