I have the following 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 ONLY shows the rows between the first and the second 'DateRecall' , but return all the rows with 'Call_Again','Busy' and 'Not_answered' without filtering the date.
Any solution will be appreciated !
Interpersonal conflict refers to any type of conflict involving two or more people. It's different from an intrapersonal conflict, which refers to an internal conflict with yourself.
One group is of those conditions which worsen Conflict Behavior generally, whether negative communications, sanctions, violence, or war. These include the sociocultural dissimilarity between the parties, their cognitive imbalance and status difference and the coercive power of the parties.
The opposing force created, the conflict within the story generally comes in four basic types: Conflict with the self, Conflict with others, Conflict with the environment and Conflict with the supernatural. Conflict with the self, the internal battle a lead character has within, is often the most powerful.
According to Amy Gallo, who wrote the Harvard Business Review Guide to Managing Conflict at Work, there are four types of work conflict: status conflict, task conflict, process conflict, and relationship conflict.
A simple IN()
would solve this:
SELECT * FROM `Contacts`
WHERE `Zona` = '1'
AND `Responsable` = '9'
AND `AllowComercialVisit` IN ('Call_Again','Busy','Not_answered')
AND `DateRecall` BETWEEN '2016-06-20 12:39:52'
AND '2016-06-20 13:04:52'
ORDER BY `DateRecall` ASC
LIMIT 1
In general, AND
has precedence over OR
, when using OR
try using parentheses ->
WHERE COND1 AND COND2 AND (COND3 OR COND4) AND COND5
Which will force the optimizer to follow your precedence and not the default one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With