题解 | #纠错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 吉林

相关推荐

king122:专业技能不要写这么多,熟悉和熟练你经不住问,排版有些难看,中间的空隙搞小一点,项目描述的话感觉是从课程中抄下来的,改一改吧,不然烂大街了,每个项目都写一两点,用什么技术实现了什么难点,然后再写一些数字上去像时间又花了90%这样,这样面试会多一些,如果觉得自己的项目还是不够用的话,我有几个大厂最近做过的实习项目,感兴趣的话可以看我简介中的项目地址
点赞 评论 收藏
分享
评论
13
1
分享

创作者周榜

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