°ïÐÄÓÅ»¯Ò»ÏÂsql - MS-SQL Server / »ù´¡Àà
declare @sql=N'SELECT TOP '+cast(@pageSize as varchar(50))+' * from (SELECT TOP ' +cast(@pageSize*@currentpage as varchar(50))+' * from [InMail] A ORDER BY A.id DESC) B ORDER BY B.id ASC' set @sql='SELECT from ('+@sql+') C ORDER BY C.id DESC' ÏÈÊÇ·ÖÃæ¡£µ«ÊǺóÃæÓÖ³öÀ´ÁËÅÅÐò²»ÕýÈ·ÁË¡£ Èç 1 2 3 4 5 6 7 8 9 ÏÂÃæÊÇ×îеġ£ÒªÏÔÊÇÔÚ×îÉÏÃæ Èç¹ûpageSize=2 currentPage=2 ÔòÒªÇóÈ¡³ö 7 6 ---------- pageSize=2 currentPage=3 5 4
²»ºÃÒâ˼£¬±êÌâ´ò´íÁË¡£ÒýÓà SQL code --> Éú³É²âÊÔÊý¾Ý±í: [InMail] IF OBJECT_ID('[InMail]') IS NOT NULL DROP TABLE [InMail] GO CREATE TABLE [InMail] ([ID] [int]) INSERT INTO [InMail] SELECT '1' UNION ALL SELECT '2' UNION ALL¡¡ ÓÐûÓпÉÒÔÓÅ»¯Ò»Ïµģ¿ ÎÒ¿¿£¬ÏÂÃæµÄʲôÌù×ÓŶ¡£°ÑÎÒÎÊÌⶼ¸ø¸ÇÏÂÈ¥ÁË¡£ÒýÓà ÎÒ¿¿£¬ÏÂÃæµÄʲôÌù×ÓŶ¡£°ÑÎÒÎÊÌⶼ¸ø¸ÇÏÂÈ¥ÁË¡£ ÄãÊÇʲô°æ±¾µÄÊý¾Ý¿â£¿ÒýÓà ÒýÓà 4 Â¥ jinfengyiye µÄ»Ø¸´: ÎÒ¿¿£¬ÏÂÃæµÄʲôÌù×ÓŶ¡£°ÑÎÒÎÊÌⶼ¸ø¸ÇÏÂÈ¥ÁË¡£ ÄãÊÇʲô°æ±¾µÄÊý¾Ý¿â£¿ Õâ¸ö²»ÊÇ£¬ÎÒÊÇ˵csdnÀïµÄÌù×Ó£¬ÄÇЩXXÌù£¬°ÑÎÒµÄÌù×Ó¸ÇÏÂÈ¥ÁË¡£ SQL code Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighl
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º 1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã© Ñ¡ÔñºÃÎļþºó µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏ 2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql 3 ......
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£ ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î date(Ö÷) outid(Ö÷) inid(Ö÷) num amt 2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£© tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname ½á¹û£º µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
ÐèÇóÈçÏ£º ѧԺ academy£¨aid,aname£© °à¼¶ class£¨cid,cname,aid£© ѧÉú stu(sid,sname,aid,cid) סËÞÇø region(rid,rname) ËÞÉáÂ¥ build(bid,rid,bnote) bnoteÊÇ¡®ÄС¯/¡®Å®¡¯ ËÞÉá dorm(did,rid,bid£¬bedn ......
Ôõô°ÑMDFÊý¾Ýתµ½MySQL£¿ ÖÁÉٵø½¼Óµ½sqlserverÉÏ ¾ßÌåÔõôŪ°¡ ÎҵıÏÒµÉè¼ÆµÄÊý¾Ý¿âÊÇ´ÓÍøÉÏdownÏÂÀ´µÄ£¿£¿ Ä㻹²»ÈçÖ±½ÓÓÃsqlserverÄØ º¯Êý¡¢´æ´¢¹ý³Ì¶¼µÃ¸ÄÁË¡£ sqlserverûÔõôÓùý¡£Ò²Ã»Óа²× ......