1
sorcerer 2022-05-19 16:20:49 +08:00 via iPhone
这。。第一反应不是 join 两次就好了?
|
3
AlkTTT 2022-05-19 17:46:10 +08:00
union all 呗
|
5
zbinlin 2022-05-21 12:04:05 +08:00
可以 join 两次表 B:
SELECT B1.name AS a_goods_name, B2.name AS b_goods_name FROM A INNER JOIN goods AS B1 ON A.a_goods_id = B1.id INNER JOIN goods AS B2 ON A.b_goods_id = B2.id; 或者使用 subquery: SELECT (SELECT name FROM goods WHERE goods.id = A.a_goods_id) AS a_goods_name, (SELECT name FROM goods WHERE goods.id = A.b_goods_id) AS b_goods_name FROM A; |