0

I have a MySQL table with the following columns: location, title and date.

I would like to search for the following

location = San Francisco OR Los Angeles
And
title = Hadoop OR Teradata
And
date = 21-5-2017 or 20-5-2017

Is that possible to do in one SQL query?

Thanks

3
  • Did you try writing the query same way? Did it work? Any error? Commented May 25, 2017 at 5:37
  • 1
    Are you really storing your dates as text (21-5-2017)? Don't do that, use a date column type. Commented May 25, 2017 at 5:43
  • No, just an example, thanks Commented May 25, 2017 at 5:44

2 Answers 2

3

Query

select * from `your_table_name`
where (`location` = 'San Francisco' or `location` = 'Los Angeles')
and (`title` = 'Hadoop' or `title` = 'Teradata')
and (`date` = '21-5-2017' or `date` = '20-5-2017');
Sign up to request clarification or add additional context in comments.

1 Comment

@LironToval : Please mark it as answer if it solved your problem.
0

Or, perhaps more elegantly...

select *
  from your_table_name
 where location IN ('San Francisco','Los Angeles')
   and title IN('Hadoop', 'Teradata')
   and date IN('2017-05-21', '2017-05-20');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.