dimanche 17 juillet 2016

OR conflict between other conditions

I have the next query:

    SELECT * FROM `Contacts` 
WHERE `Zona` = '1' 
AND `Responsable` = '9' 
AND `AllowComercialVisit` = 'Call_Again'
-- the problem are OR's --
OR `AllowComercialVisit` = 'Busy' 
OR `AllowComercialVisit` = 'Not_answered' 
-- the problem are OR's --
AND `DateRecall` <= '2016-06-20 13:04:52' 
AND `DateRecall` >= '2016-06-20 12:39:52' 
ORDER BY `DateRecall` ASC LIMIT 1

The problem is that the query should show ONLY the rows between first and second 'DateRecall' but return all the rows with 'Call_Again','Busy' and 'Not_answered'.

Any solution?

Aucun commentaire:

Enregistrer un commentaire