多表搜索问题

WBOY
Release: 2016-06-23 14:40:17
Original
928 people have browsed it

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);
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template