SQL:
WITH joined AS (
SELECT *
FROM table_a a
JOIN table_b b ON (a.a_id = b.a_id)
)
SELECT a_id
FROM joined
返回无效标识符。
使用 WITH 子句时如何选择连接列?我尝试了别名、前缀,但没有任何效果。我知道我可以使用:
WITH joined AS (
SELECT a.a_id
FROM table_a a
JOIN table_b b ON (a.a_id = b.a_id)
)
SELECT a_id
FROM joined
但我需要这个别名来涵盖所有领域。
我设法满足这个条件的唯一方法是使用:
WITH joined AS (
SELECT a.a_id a_id_alias, a.*, b.*
FROM table_a a
JOIN table_b b ON (a.a_id = b.a_id)
)
SELECT a_id_alias
FROM joined
但这不是完美的解决方案...