condition in below query returning true result but i want false result. Please suggest me.
select *
from test
where
'00160001' between '0013001' and '0023000' OR
'00200000' between '0013001' and '0023000'
condition in below query returning true result but i want false result. Please suggest me.
select *
from test
where
'00160001' between '0013001' and '0023000' OR
'00200000' between '0013001' and '0023000'
You get the same result without the leading zeros.
Use integer data type to compare integer values.
You can also convert the values on the fly using cast:
Your example with Cast:
select if( cast('00160001' as unsigned) between cast('0013001' as unsigned)
and cast('0023000' as unsigned),1,0) as test_a,
if( cast('00200000' as unsigned) between cast('0013001' as unsigned)
and cast('0023000' as unsigned),1,0) as test_b;