这是'关系'表
这是'relationship_funder'表
要连接两个表,请执行
select * from relationship
join relationship_funder on relationship.id = relationship_funder.relationship_id
我现在面临的问题是只生成一个sql
'buyer_id或funder_id之一是23或者buyer_id和funder_id都是23'
应该显示
答案 0 :(得分:1)
添加WHERE
子句:
SELECT *
FROM relationship r
INNER JOIN relationship_funder rf
ON r.id = rf.relationship_id
WHERE
r.buyer_id = 23 OR rf.funder_id = 23;