mysql 根据字段值来判断left join哪个表

2024-11-29 21:43:36
推荐回答(1个)
回答1:

SELECT * FROM A as a
LEFT JOIN B as b ON a.type_id = b.id AND a.type_id = 1

LEFT JOIN C as c ON a.type_id = c.id AND a.type_id = 2;

基本思路就是使用JOIN ON AND命令。