Fabian Tschullik
Fabian Tschullik

Reputation: 145

MySQL select with "between" and "AND"

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.

Upvotes: 4

Views: 9704

Answers (2)

Pythonsguru
Pythonsguru

Reputation: 452

Try this worked for me:

delete from table_name where column_name between '2018-06-01 09:00:00' and '2018-10-01 18:00:00';

Upvotes: 0

Mansoor
Mansoor

Reputation: 4192

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

Upvotes: 8

Related Questions