SQL select查询 - 从不同的字段中选择

时间:2017-05-25 05:35:30

标签: mysql sql

我有一个包含以下列的MySQL表:位置,标题和日期。

我想搜索以下内容

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

这可以在一个SQL查询中执行吗?

由于

2 个答案:

答案 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');
相关问题