下面这个语句查询的是根据id得到同类型的上下12。这里我们先找这24条记录,在让pvVideoID处于这个范围中将2部分查询结果合并起来,最后还可排序
create proc QsqProfessionalVideo_Get_OnproId
@proId int =null
as
select * from QsqProfessionalVideo where pvVideoID in(
select top 12 pvVideoID from QsqProfessionalVideo where
pvType =(select pvType from QsqProfessionalVideo where pvVideoID=@proId) and pvVideoID<@proId order by pvCreated desc
) or pvVideoID in (
select top 12 pvVideoID from QsqProfessionalVideo where
pvType =(select pvType from QsqProfessionalVideo where pvVideoID=@proId ) and pvVideoID>@proId order by pvCreated
)
order by pvCreated
GO
@proId int =null
as
select * from QsqProfessionalVideo where pvVideoID in(
select top 12 pvVideoID from QsqProfessionalVideo where
pvType =(select pvType from QsqProfessionalVideo where pvVideoID=@proId) and pvVideoID<@proId order by pvCreated desc
) or pvVideoID in (
select top 12 pvVideoID from QsqProfessionalVideo where
pvType =(select pvType from QsqProfessionalVideo where pvVideoID=@proId ) and pvVideoID>@proId order by pvCreated
)
order by pvCreated
GO
数据库中“时间”,“整数”查询不能模糊查询,只能用“< = >” 例如:
select * from expert where beginTime >= #2008-9-9# and beginTime< #2008-9-10#
进入access的查询:查询—设计视图中创建查询—设计—(关闭显示表)—点上面的sql