日期:2014-05-17 浏览次数:20685 次
表1[Table1]
字段:
[id] [int] IDENTITY(1,1) NOT NULL,
[k] [varchar](50) NOT NULL,
[d] [datetime] NOT NULL
表2[Table2]
字段:
[id] [int] IDENTITY(1,1) NOT NULL,
[t3_Id] [int] NOT NULL,
[t1_Id] [int] NOT NULL,
[date] [datetime] NOT NULL
表3[Table3]
[id] [int] IDENTITY(1,1) NOT NULL,
[title] [varchar](50) NOT NULL,
[conten] [varchar](50) NOT NULL,
[date] [datetime] NOT NULL
表1存放的是关键字,表3存放的是文章,表2存放的是文章中包含的关键字
根据关键字查询
declare @t1_Id int;
Select @t1_Id = id from Table1 where k = 'test1'
Select t3.title,t3.conten from Table2 t2,Table3 t3 where t2.t1_Id = @kt_Id and t3.id = t2.t3_Id
/*通用分页存储过程*/
USE HotelManagementSystem
GO
IF EXISTS(SELECT * FROM sys.objects WHERE NAME='cndoup_GetPageOfRecords')
DROP PROCEDURE cndoup_GetPageOfRecords
GO
--创建存储过程
CREATE PROCEDURE cndoup_GetPageOfRecords
@pageSize int = 20, --分页大小
@currentPage int , --第几页
@columns varchar(1000) = '*', --需要得到的字段
@tableName varchar(100), --需要查询的表
@condition varchar(1000) = '', --查询条件, 不用加where关键字
@ascColumn varchar(100) = '', --排序的字段名 (即 order by column asc/desc)
@bitOrderType bit = 0, --排序的类型 (0为升序,1为降序)
@pkColumn varchar(50) = ''