所以我有这个问题:
select
id,
unnest(suppliers) as suppliercode
from table1 t1
left join table2 t2
on t1.suppliercode = t2.suppliercode
Postgres无法理解其含义:
on t1.suppliercode = t2.suppliercode
t2.suppliercode 引起混淆。为什么?如何显式调用新的派生列?
答案 0 :(得分:1)
t1.suppliercode
表示“表suppliercode
中的列t1
”。而你的表t1
没有这样的列。尝试类似:
select *
from(select t1.id,
unnest(t1.suppliers) as suppliercode
from table1 t1 ) sub
left join table2 t2
on sub.suppliercode = t2.suppliercode