考试报名
考试报名
考试内容
考试大纲
在线客服
返回顶部

备考刷题,请到

CDA认证小程序

在以下语句中,哪个是查询所有t1表中城市名为空的记录
A. select * from t1 where city_name not null;
B. select * from t1 where city_name is not null;
C. select * from t1 where city_name null;
D. select * from t1 where city_name is null;
上一题
下一题
收藏
点赞
评论
题目解析
题目评论(0)

本题考查SQL语句中空值的查询方法。其中is not null表示没有空值,is null表示有空值,故正确答案为D

在给定的选项中,要查询所有 `t1` 表中城市名为空的记录,正确的 SQL 语句是选项 D。

选项分析:
A: `select * from t1 where city_name not null;`
- 这个语句是错误的,因为 SQL 中判断是否为空值应该使用 `IS NULL` 或 `IS NOT NULL`,而不是直接使用 `not null`。

B: `select * from t1 where city_name is not null;`
- 这个语句用于查询城市名不为空的记录,与问题要求相反。

C: `select * from t1 where city_name null;`
- 这个语句是错误的,因为 `null` 前面缺少 `IS` 关键字。

D: `select * from t1 where city_name is null;`
- 这个语句是正确的,用于查询城市名为空的记录。

因此,正确答案是 D: `select * from t1 where city_name is null;`。