如何在单个SQL语句的where子句中使用两个LIKE?

时间:2018-10-17 08:56:49

标签: mysql sql

{{1}}

2 个答案:

答案 0 :(得分:0)

我认为在出现条件的情况下您选择了错误的列名

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'

答案 1 :(得分:0)

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