题解 | #纠错4#

纠错4

http://www.nowcoder.com/practice/bde1451b91084c8cab467387a0e0969c

两种方法:

方法一:

使用union子句进行双重查询,再将两次查询的结果结合在一起,但是由于使用了union子句,所以order by 子句只能使用一次且只能在最后一个 select 中使用;具体如下:

select cust_name,cust_contact,cust_email
from Customers
where cust_state = 'MI'
union
select cust_name,cust_contact,cust_email
from Customers
where cust_state = 'IL'
order by cust_name

方法二: 使用 or 进行多条件查询,具体如下:

select cust_name,cust_contact,cust_email
from Customers
where cust_state = 'MI'
or cust_state = 'IL'
order by cust_name
全部评论
方法三:select cust_name,cust_contact,cust_email from Customers where cust_state in ('MI','IL') order by cust_name
1 回复 分享
发布于 2022-12-28 15:23 浙江
为什么是or 不是 and
点赞 回复 分享
发布于 2023-05-27 13:59 吉林

相关推荐

04-21 11:22
已编辑
中华女子学院 UE4
耐心学习_佩可officical:直接举报他,佬,违反劳动法我记得boss会下架
点赞 评论 收藏
分享
06-13 17:00
武汉大学 Java
6月了还有点击就送的offer吗😭,投麻了😢
叫我阿东就行:这个bg,也还没找到理想的工作吗?好难,好焦虑
点赞 评论 收藏
分享
评论
13
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务