Dev Dev - 3 months ago 6
SQL Question

MYSQL Database Query not giving back expected results

I have a database which has the configuration as shown in the picture
Config of Database Table

I am trying to query

SELECT * FROM emails WHERE ('from_type=Manager' OR 'to_type=Manager') AND ('from=2' OR 'to=2')


It is giving me back a blank result, even though I think it should give me the one query I have set,

enter image description here

Answer

Try this Code and let me know if you get your Desired Output.

SELECT * FROM emails 
WHERE (`from_type`= 'Manager' OR `to_type`='Manager') AND (`from`='2' OR `to`='2')