ÈýÖÐSQL ·ÖÒ³·½·¨Ð§ÂÊ·ÖÎö
ÈýÖÖSQL·ÖÒ³·¨Ð§ÂÊ·ÖÎö
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
¡¡Óï¾äÐÎʽ£ºÀûÓÃNot InºÍSELECT TOP·ÖÒ³) ЧÂÊÖУ¬ÐèҪƴ½ÓSQLÓï¾ä
SELECT TOP 10 * from TestTable WHERE (Id NOT IN (SELECT TOP 20 id from TestTable ORDER BY id )) ORDER BY ID
2.·ÖÒ³·½°¸¶þ£º(ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£ºÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³)ЧÂÊ×î¸ß£¬ÐèҪƴ½ÓSQLÓï¾ä
SELECT TOP 10 * from TestTable WHERE (ID > (SELECT MAX(id) from (SELECT TOP 20 id from TestTable ORDER BY id) AST))
3.·ÖÒ³·½°¸Èý£º(ÀûÓÃSQLµÄÓÎ±ê´æ´¢¹ý³Ì·ÖÒ³)
Óï¾äÐÎʽ£ºÀûÓÃSQLµÄÓÎ±ê´æ´¢¹ý³Ì·ÖÒ³) ЧÂÊ×î²î£¬µ«ÊÇ×îΪͨÓÃ
create procedure SqlPager
@sqlstr nvarchar(4000), --²éѯ×Ö·û´®
@currentpage int, --µÚNÒ³
@pagesize int --ÿҳÐÐÊý
as
set nocount on
declare @P1 int, --P1ÊÇÓαêµÄid
@rowcount int
exec sp_cursoropen @P1 output,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcount output
select ceiling(1.0*@rowcount/@pagesize) as ×ÜÒ³Êý--,@rowcount as ×ÜÐÐÊý,@currentpage as µ±Ç°Ò³
set @currentpage=(@currentpage-1)*@pagesize+1
exec sp_cursorfetch @P1,16,@currentpage,@pagesize
exec sp_cursorclose @P1
set nocount off
Ïà¹ØÎĵµ£º
1.ʹÓÃPHPµÄMSSQL,ÐèÒª¼ÓÔØPHPµÄMSSQLÀ©Õ¹¡£¾ßÌå·½·¨ÊÇ´ò¿ªphp.iniÎļþ£¬ÕÒµ½ÏÂÃæÒ»ÐдúÂ룺
;extension=php_mssql.dll
È¥µôÐÐÊ׵ķֺţ¬È»ºó±£´æÎªphp.iniÎļþ£¬¼´Íê³ÉPHPµÄMSSQLÀ©Õ¹µÄ¼ÓÔØ¡£
2.PHPÁ¬½ÓSQL ServerµÄ±ØÒªÌõ¼þ
a. SQL Server·þÎñÆ÷µÄÖ÷»úÃû³Æ¡£
b. ÔÊÐí¶Ô·þÎñÆ÷ ......
×Ô£ºhttp://blog.csdn.net/AJAXBloger/archive/2007/08/29/1764506.aspx
×Ó²éѯ£º
ʹÓÃ×Ó²éѯµÄÔÔò
1.Ò»¸ö×Ó²éѯ±ØÐë·ÅÔÚÔ²À¨ºÅÖС£
2.½«×Ó²éѯ·ÅÔڱȽÏÌõ¼þµÄÓÒ±ßÒÔÔö¼Ó¿É¶ÁÐÔ¡£
×Ó²é
ѯ²»°üº¬ ORDER BY ×Ӿ䡣¶ÔÒ»¸ö SELECT Óï¾äÖ»ÄÜÓÃÒ»¸ö ORDER BY ×Ӿ䣬
²¢ÇÒÈç¹ûÖ¸¶¨ÁËËü¾Í±ØÐë·ÅÔÚÖ÷
SELECT Óï¾äµÄ×î ......
¡¶SQL Sever 2005 Êý¾Ý¿â»ù´¡¼°Ó¦Óü¼Êõ½Ì³ÌÓëʵѵ ¡· ÖÜÆæ
SQL Server 2005µÄ°æ±¾£º
1. SQL Server 2005 Enterprise Edition ÆóÒµ°æ(32λºÍ64λ)
ÊÊÓÃÓÚ³¬´óÐÍÆóÒµ¡£Enterprise Edition ÊÇ×îÈ«ÃæµÄSQL Server°æ±¾£¬Êdz¬´óÐÍÆóÒµµÄÀíÏëÑ¡Ôñ£¬Äܹ»Âú×ã×ÔÓµÄÒªÇ󡣸ð汾»¹Í ......
1¡¢Ê¹ÓÃË÷ÒýÀ´¸ü¿ìµØ±éÀú±í¡£
ȱʡÇé¿öϽ¨Á¢µÄË÷ÒýÊÇ·ÇȺ¼¯Ë÷Òý£¬µ«ÓÐʱËü²¢²»ÊÇ×î¼ÑµÄ¡£ÔÚ·ÇȺ¼¯Ë÷ÒýÏ£¬Êý¾ÝÔÚÎïÀíÉÏËæ»ú´æ·ÅÔÚÊý¾ÝÒ³ÉÏ¡£ºÏÀíµÄË÷ÒýÉè¼ÆÒª½¨Á¢ÔÚ¶Ô¸÷ÖÖ²éѯµÄ·ÖÎöºÍÔ¤²âÉÏ¡£
Ò»°ãÀ´Ëµ£º
a.ÓдóÁ¿Öظ´Öµ¡¢ÇÒ¾³£Óз¶Î§²éѯ£¨ > ,< £¬> =,< =£©ºÍorder by¡¢group by·¢ÉúµÄÁУ¬¿É¿¼
Âǽ ......