Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL select with "between" and "AND"

Tags:

sql

mysql

between

i have this part of an sql select:

where `zipCode` between "40000" and "42000"
OR `zipCode` between "50000" and "51000"
OR `zipCode` between "53000" and "60000"
AND plan = "sell" 
AND created_at > '2017-01-01' 
AND clone_id is not null

I'm getting the correct range of the zipCode back. But the condition with "plan" "ceated_at" and "clone_id" is not working.

like image 869
Fabian Tschullik Avatar asked Mar 09 '23 18:03

Fabian Tschullik


1 Answers

Try below query :

where ( `zipCode` between "40000" and "42000" OR `zipCode` between "50000" and   
"51000" OR `zipCode` between "53000" and "60000" )
AND plan = "sell" AND created_at > '2017-01-01' AND clone_id is not null
like image 151
Mansoor Avatar answered Mar 21 '23 00:03

Mansoor