We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
找出所有从不订购任何东西的客户
create table customers ( id int primary key auto_increment, name varchar(255) ); insert into customers (name) values('Joe'), ('Henry'), ('Sam'), ('Max'); create table orders ( id int primary key auto_increment, customerId int ); insert into orders (customerId) values(3),(1);
select name from customers left join orders on customers.id = orders.customerId where isnull(customerId);
使用 left join 连接 customers 和 orders 连接条件是 customers.id = orders.customersId and isnull(customersId)
left join
customers
orders
customers.id = orders.customersId and isnull(customersId)
select name from customers where id not in ( select customerId from orders );
使用 not in 查出不在这些结果中的数据。
not in
select name from customers where not exists ( select customerId from orders where customerId = customers.id );
使用 not exists 代替 not in
not exists
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目
找出所有从不订购任何东西的客户
SQL:方法一
解析
使用
left join
连接customers
和orders
连接条件是customers.id = orders.customersId and isnull(customersId)
SQL:方法二
解析
使用
not in
查出不在这些结果中的数据。SQL:方法三
解析
使用
not exists
代替not in
The text was updated successfully, but these errors were encountered: