2017-03-01 57 views
0

我有一个SQL的这部分选择:MySQL的选择具有“之间”与“和”

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 

我得到正确的范围内,邮编回来。但随着“规划”,“ceated_at”和“clone_id”的条件是行不通的。

+0

u能提供一个数据样本,与你预期的输出和输入数据? –

回答

2
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