我有 5 张 table 。
我想获取表 1、2 和 3 中不在表 4 和 5 中的普通用户。
谁能帮帮我:)
表格
table1(userid,discount)
table2(userid,discount)
table3(userid,discount)
table4(userid,discount)
table5(userid,discount)
最佳答案
一种方法,在表行上左连接以省略:
select *
from table1 a
join table2 b on (a.userid = b.userid)
join table3 c on (a.userid = c.userid)
left join table4 d on (a.userid = d.userid)
left join table5 e on (a.userid = e.userid)
where d.userid is null and e.userid is null;
关于mysql - SQL查找多个表中的普通用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33340184/