sql查询分析高手进来指导下

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:54:20
select * from news where news_data like '%关键字%'
select * from news where news_title like '%关键字%'
select * from news where news_date between '时间1' and '时间2'

怎么整合这三句话 …… 用或者的关系查询

select * from news where (news_data like '%关键字%') or (news_title like '%关键字%') or (news_date between '时间1' and '时间2')

如过是3选1 就是or
如果是3者都要 就是and

你第3句不是已经有个and 了么.. 全用这个就可以了

他们都回答出了,我就回答你这个不是问题的问题。。。。
这个and是两个时间之间,并不是在几个条件之间。
between是两数之间,,就像

求年龄在20与22岁之间(包括20 和 22)的学生的学号和年龄
select number,age
from s
where age between 20 and 22 这样。

也可以用union,返回查询结果集
select * from news where news_data like '%关键字%'
union
select * from news where news_title like '%关键字%'
union
select * from news where news_date between '时间1' and '时间2'

你第3句不是已经有个and 了么.. 全用这个就可以了