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

备考刷题,请到

CDA认证小程序

select * from student where sno='05880101'union select * from student where sno='05880102'与此查询语句等价的选项是( )。
A. select * from student where sno=’05880101’ and sno= ’05880102’
B. select * from student where sno=’05880101’ or sno= ’05880102’
C. select * from student where sno=’05880101’
D. select * from student where sno=’05880102’
上一题
下一题
收藏
点赞
评论
题目解析
题目评论(0)

正确答案是 B: `select * from student where sno='05880101' or sno='05880102'`。

分析:

1. `union` 操作用于合并两个或多个 `select` 语句的结果集。`union` 会去除重复的记录,并将两个查询的结果组合在一起。

2. 原始查询语句:
```sql
select * from student where sno='05880101'
union
select * from student where sno='05880102'
```
这表示从 `student` 表中选择学号为 `05880101` 或 `05880102` 的记录。

3. 选项分析:
- A: `select * from student where sno='05880101' and sno='05880102'`:这个语句试图选择学号同时为 `05880101` 和 `05880102` 的记录,这是不可能的,因为一个字段不可能同时有两个不同的值。
- B: `select * from student where sno='05880101' or sno='05880102'`:这个语句正确地表示选择学号为 `05880101` 或 `05880102` 的记录,与原始查询语义相同。
- C: `select * from student where sno='05880101'`:这个语句只会选择学号为 `05880101` 的记录,缺少了学号为 `05880102` 的记录。
- D: `select * from student where sno='05880102'`:这个语句只会选择学号为 `05880102` 的记录,缺少了学号为 `05880101` 的记录。

因此,选项 B 是与原始查询等价的正确答案。