【发布时间】:2020-07-31 17:43:24
【问题描述】:
我有三张桌子:
t_tbl
-----
t_id PK
t
p_tbl
-----
p_id PK
p
x_tbl
-----
x_id PK
x
t_id
p_id
我的搜索单独工作:
查询 1:
SELECT x
FROM x_tbl xt
INNER JOIN
t_tbl tt
ON
xt.t_id = tt.t_id
查询 2:
SELECT x
FROM x_tbl xt
INNER JOIN
p_tbl pt
ON xt.p_id = pt.p_id
但我想得到xt.x if xt.t_id = tt.t_id OR xt.p_id = pt.p_id
【问题讨论】:
标签: sql postgresql join