我有一个包含以下列的MySQL表:位置,标题和日期。
我想搜索以下内容
location = San Francisco OR Los Angeles
And
title = Hadoop OR Teradata
And
date = 21-5-2017 or 20-5-2017
这可以在一个SQL查询中执行吗?
由于
答案 0 :(得分:3)
<强>查询强>
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');
答案 1 :(得分:0)
或者,或许更优雅......
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');