Reputation: 9474
I have a table say, events and fields are
id, event_id, dest_event_id
I would like to check my passed Ids of array into both the columns
so, I have done it via two separate queries.
SELECT * FROM events WHERE event_id IN ('123' , '345');
if not,
SELECT * FROM events WHERE dest_event_id IN ('123' , '345');
How can I do it using single query? can I use find_in_set?
NOTE: want to check in dest_event_id when record does not exists in event_id
Thanks for your help
Upvotes: 0
Views: 36
Reputation: 31
Please try with the following Query
SELECT * FROM events WHERE 123 IN (event_id, dest_event_id) OR
345 IN (event_id, dest_event_id);
Upvotes: 0
Reputation: 2180
You just have to put both conditions together:
SELECT * FROM events WHERE event_id IN ('123' , '345') or dest_event_id IN ('123' , '345')
Upvotes: 1