如何在一条sql语句中使用两个like-in-where子句?

icnyk63a  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(264)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

两年前关门了。
改进这个问题

select * from SMS_Send s 
where (s.ReceiverNo  like '071' or s.SchduledD like '078') 
and SchduledD between '2018-08-01 00:00:00.000' and '2018-08-31 00:00:00.000'
order by SchduledD
cgh8pdjw

cgh8pdjw1#

select * from SMS_Send s 
where s.ReceiverNo  like '071' or s.SchduledD like '078' 
and s.SchduledD >= '2018-08-01 00:00:00.000' and s.SchduledD <='2018-08-31 00:00:00.000'
order by SchduledD
ruoxqz4g

ruoxqz4g2#

我想你选错了列名,以防出现where情况

select * from SMS_Send s 
where (s.ReceiverNo='071' or s.ReceiverNo ='078')  
and date_data_type_column  '2018-08-01 00:00:00.000' and '2018-08-31 00:00:00.000'-- wrong column name here date column need
order by SchduledD

为了 (s.ReceiverNo like '071' or s.SchduledD like '078') 这个条件你可以用 in 就像下面一样

s.ReceiverNo in (071,078)
``` `SchduledD between '2018-08-01 00:00:00.000' and '2018-08-31 00:00:00.000'` 对于这种情况,您必须在表的列中选择日期数据类型,我假设scheduleddate是表的日期类型列

ScheduledDate between '2018-08-01 00:00:00.000' and '2018-08-31 00:00:00.000'

相关问题