信息表中按照用户编号分组 然后每个用户取出按时间排序的前三条记录 并且信息标题 like '%aa%'等多个where 条件
我的上个帖子有人回答
select * from tb t where id in
(
select top 3 id from tb where 用户编号=t.用户编号
where--你的多个条件
order by 时间 desc
)
where--你的多个条件由于我的where条件很多 而且查了两遍 所以在前台分页显示的时候速度要至少半分钟才显示数据 不知道有没有高手帮我提供另外的想法 或是让查询速度变快呢?很急!多多回帖!
我的上个帖子有人回答
select * from tb t where id in
(
select top 3 id from tb where 用户编号=t.用户编号
where--你的多个条件
order by 时间 desc
)
where--你的多个条件由于我的where条件很多 而且查了两遍 所以在前台分页显示的时候速度要至少半分钟才显示数据 不知道有没有高手帮我提供另外的想法 或是让查询速度变快呢?很急!多多回帖!
--接下可以考虑在 id 用户编号 和时间 在建立索引
--接下来就可以
select * from tb t where id in
(
select top 3 id from tb where 用户编号=t.用户编号
order by 时间 desc
)