Skip to content
New issue

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

34 寻找用户推荐人 #41

Open
astak16 opened this issue Jan 31, 2022 · 0 comments
Open

34 寻找用户推荐人 #41

astak16 opened this issue Jan 31, 2022 · 0 comments
Labels

Comments

@astak16
Copy link
Owner

astak16 commented Jan 31, 2022

题目

查找推荐人的编号不是 2

create table customer(
	id int,
	name varchar(255),
	referee_id int
);

insert into customer values
(1, 'Will', null),
(2, 'Jane', null),
(3, 'Alex', 2),
(4, 'Bill', null),
(5, 'Zack', 1),
(6, 'Mark', 2);

SQL

select name from customer where ifnull(referee_id, 0) != 2 or referee_id != 2;

解析

这题的主要考点在于 SQL 中判断 null 的方法

判断 referee_idnull 的方法:

  • is null
  • isnull()
  • ifnull()
@astak16 astak16 added the 简单 label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant