当前位置: 代码迷 >> PHP >> 多表搜索有关问题
  详细解决方案

多表搜索有关问题

热度:11   发布时间:2016-04-28 18:11:48.0
多表搜索问题
A表
user_id        name
1                  张三
2                  李四
3                  王五
4                  麻子

B表
id           user_id  ..................
1               1
2               4

如何用一句MYSQL语句搜索出A表中的2,3(即李四和王五):也就是说列出B表中没有的user_id

------解决思路----------------------

select * from A where user_id not in(select user_id from B);
  相关解决方案