Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÅ»¯µÄms sql server·ÖÒ³sqlÓï¾ä

ÓÅ»¯µÄms sql server·ÖÒ³sqlÓï¾ä
·¢²¼Ê±¼ä: 2009-8-15 00:00 |  ·¢²¼×÷Õß: hjh |   |  ²é¿´: 3´Î
Ìص㣺һ´Î²éѯ£¬Êý¾Ý¿âDatabnseÖ»·µ»ØÒ»Ò³µÄÊý¾Ý¡£¶ø·ñÔòÈ¡³öËùÓеÄÊý¾Ý¡£
˵Ã÷£º
pagesize£º ÿҳ³ÊÏּǼÊý
cureentpage£ºµ±Ç°Ò³Êý
select * from ( select TOP pagesize * from ( SELECT TOP pagesize*cureentpage * from user_table ORDER BY id ASC ) as aSysTable ORDER BY id DESC ) as bSysTable ORDER BY id ASC
Àý×Ó˵Ã÷£º
¼ÙÈçÊý¾Ý¿âDatabnse±íÈçÏ£º
user_table:
id:Ö÷¼ü£¬×ÔÔö
username:×Ö·û
password:×Ö·û
¼ÙÉèÓÐ80Ìõ¼Ç¼£¬Ã¿Ò³³ÊÏÖ10Ìõ¼Ç¼£¬id ´Ó1µ½80
Ä¿Ç°°´ÕÕidÉýÐòÅÅÁÐÈ¡³öµÚÈýÒ³µÄÊý¾ÝÒò¸ÃΪ£ºËùÈ¡µÃ¼Ç¼µÄid Òò¸ÃΪ 21µ½30¡£
Õâʱ¸ÃÓï¾äÒò¸ÃΪ£º
select * from ( select TOP 10 * from ( SELECT TOP 30 * from user_table ORDER BY id ASC ) as aSysTable ORDER BY id DESC ) as bSysTable ORDER BY id ASC
˼ÏëÈçÏ£º
ÏÈ°´ÕÕid´ÓСµ½´óÉýÐòÈ¡³ö30Ìõ¼Ç¼£¨3*10£©,Ò²¾Í£ºid ÔÚ 1-30 Ö®¼äµÄ¼Ç¼ £¨SELECT TOP 30 * from user_table ORDER BY id ASC£©
È»ºó°´ÕÕID½µÐòÅÅÁÐÕâ30Ìõ¼Ç¼£¬µÃµ½¼Ç¼Ϊid ÔÚ£º´Ó30µ½ 1
È»ºóÔÚÕâÒ»²¿·Ý30Ìõ¼Ç¼ÖÐÈ¡³öÇ°10Ìõ¼Ç¼£ºÈ¡µÃµÄ¼Ç¼Ϊ£ºid ÔÚ30-21Ö®¼ä¡£Õâ¾ÍÔÛÃÇÐèÇóµÄÊý¾Ý£¬µ«ÕâʱÊÇ°´ÕÕ½µÐòÅÅÁеģ¬²»·ûºÏÒªÇó¡£
×îºóÔÚÖØÐÂÅÅÐòµÃµ½×îÖÕÔÛÃÇÐèÇóµÄÊý¾Ý¡£idÔÚ21-30Ö®¼ä¡£
ÆÚÍû¶Ô´ó²¿·ÝÈËÓÐËù°ïÖú¡£
ÈçÓÐÒÉÄÑÎÊÌ⣬ÆÚÍûºÍ´ó²¿·ÝÈËÒ»¿é¹µÍ¨¡£
email:yanek@126.com


Ïà¹ØÎĵµ£º

SQL Server2000 ½âÎöXML

DECLARE @HDOC INT --Îĵµ¾ä±ú
DECLARE @XMLSTRING VARCHAR(200) --XML×Ö·û´®
SET @xmlString ='<?xml version="1.0"?>
<ROOT>
<USER ID="1" Name="SBQCEL"/>
<USER ID="2" Name="PEACELI"/>
<USER ID="3" Name="SHEEPCHANG"/>
</ROOT>'
--ʹÓÃϵͳ´æ´¢ ......

SQLITE SQLÓï¾äµÄ×¢Òâ


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......

sqlÓï¾ä

±È½Ï³£ÓõÄSQLÓï¾äÓï·¨(Oracle)
Ò».Êý¾Ý¿ØÖÆÓï¾ä (DML) ²¿·Ö
1.INSERT  (ÍùÊý¾Ý±íÀï²åÈë¼Ç¼µÄÓï¾ä)
INSERT INTO ±íÃû(×Ö¶ÎÃû1, ×Ö¶ÎÃû2, ……) VALUES ( Öµ1, Öµ2, ……);
INSERT INTO ±íÃû(×Ö¶ÎÃû1, ×Ö¶ÎÃû2, ……)  SELECT ×Ö¶ÎÃû1, ×Ö¶ÎÃû2, …&he ......

SQL Server´¥·¢Æ÷´´½¨¡¢É¾³ý¡¢Ð޸ġ¢²é¿´Ê¾Àý½Ì³Ì

Ò»﹕
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì﹐Ëü²»Äܱ»ÏÔʽµØµ÷ÓÃ﹐¶øÊÇÔÚÍù±íÖвåÈë¼Ç¼﹑¸üмǼ»òÕßɾ³ý¼Ç¼ʱ±»×Ô¶¯µØ¼¤»î¡£ËùÒÔ´¥·¢Æ÷¿ÉÒÔÓÃÀ´ÊµÏÖ¶Ô±íʵʩ¸´ÔÓµÄÍê
ÕûÐÔÔ¼`Êø¡£
        
¶þ﹕ SQL
ServerΪÿ¸ö´¥·¢Æ÷¶¼´´½¨ÁËÁ½¸öרÓñí᥮ ......

SQLÁ¬½Ó²éѯ(»ã×Ü)

Ò»¡¢½»²æÁ¬½Ó£¨CROSS JOIN£©
½»²æÁ¬½Ó£¨CROSS JOIN£©£ºÓÐÁ½ÖÖ£¬ÏÔʽµÄºÍÒþʽµÄ£¬²»´øON×Ӿ䣬·µ»ØµÄÊÇÁ½±íµÄ³Ë»ý£¬Ò²½ÐµÑ¿¨¶û»ý¡£
ÀýÈ磺ÏÂÃæµÄÓï¾ä1ºÍÓï¾ä2µÄ½á¹ûÊÇÏàͬµÄ¡£
Óï¾ä1£ºÒþʽµÄ½»²æÁ¬½Ó£¬Ã»ÓÐCROSS JOIN¡£
SELECT O.ID, O.ORDER_NUMBER, C.ID, C.NAME
from ORDERS O , CUSTOMERS C
WHERE O.ID=1;
Óï¾ä2£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ