MSSQL ʵÏÖ MySQL µÄ limit ²éѯ·½Ê½
MSSQL ÈçºÎʵÏÖ MySQL µÄ limit ²éѯ·½Ê½
²»ÖªÎªºÎ£¬MSSQL ÖÐûÓÐ limit Õâ¸ö¼«ÎªÖØÒªµÄ²éѯ·½Ê½£¬ÊìϤ MySQL µÄÅóÓѶ¼ÖªµÀ£¬MySQL µÄ limit ¶ÔÓÚʵÏÖ·ÖÒ³ºÍһЩÏÞÖƽá¹û¼¯µÄÓ¦ÓÃÖзdz£·½±ã¡£Ã»Óв»Òª½ô£¬ÎÒÃÇ¿ÉÒÔÓÃÆäËû·½·¨´ïµ½Í¬ÑùµÄÄ¿µÄ£¬×Ô¼º¶¯ÊÖ£¬·áÒÂ×ãʳ£¡
Óï·¨£º
Code:
SELECT * from
(
SELECT TOP [ÿҳ¼Ç¼]
* from
(
SELECT TOP [ÿҳ¼Ç¼*µ±Ç°Ò³Êý]
[×Ö¶Î1, ×Ö¶Î2, ...]
from [Êý¾Ý±í]
ORDER BY [ÅÅÐò×Ö¶Î]
DESC
)
[±í±ðÃû1]
ORDER BY [ÅÅÐò×Ö¶Î]
)
[±í±ðÃû2]
ORDER BY [ÅÅÐò×Ö¶Î]
DESC
ʾÀý£º
Code:
SELECT * from
(
SELECT TOP 5 * from
(
SELECT TOP 10 *
from table
ORDER BY id DESC
) t1
ORDER BY id
) t2
ORDER BY id DESC
ÉÏÃæµÄ´úÂë±íʾ´Ó table ±íÖлñÈ¡¼Ç¼£¬Ã¿Ò³5Ìõ¼Ç¼£¬µ±Ç°ÊǵڶþÒ³5*2=10£¬½á¹û°´ÕÕ id µ¹ÐòÅÅÁС£
Ïà¹ØÎĵµ£º
ÆäʵÈç¹ûÄã·þÎñÆ÷ÖØа²×°ÁË,Ò²²»±ØÖØа²×°mysql ¼¸¸öСÃüÁî¾Í¸ã¶¨ÁË
Ê×ÏÈÊÇ°²×°mysql·þÎñ:
mysql-nt –install
net start mysql
µ±È»Ó´ÔÚbinĿ¼ÔËÐÐÕâ¸öÃüÁîÁË
жÔصÄÃüÁîÊÇ:
net stop "MySQL"
mysqld-nt.exe –remove "MySQL"
ΪʲôÓеÄÅóÓÑжÔز»ÁËÄØ,ÒòΪËûÒѾ°ÑÔ´Îļþ¶¼É¾³ýÁË »òÕßÔËÐÐÐ ......
Transact_SQLСÊÖ²á
*******************Transact_SQL********************
--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT & ......
ÊýÖµÀàÐÍ
¡¡¡¡MySQL
µÄÊýÖµÊý¾ÝÀàÐÍ¿ÉÒÔ´óÖ»®·ÖΪÁ½¸öÀà±ð£¬Ò»¸öÊÇÕûÊý£¬ÁíÒ»¸öÊǸ¡µãÊý»òСÊý¡£Ðí¶à²»Í¬µÄ×ÓÀàÐͶÔÕâЩÀà±ðÖеÄÿһ¸ö¶¼ÊÇ¿ÉÓõģ¬Ã¿¸ö×ÓÀàÐÍÖ§³Ö²»Í¬´óСµÄÊý¾Ý£¬²¢ÇÒ
MySQL ÔÊÐíÎÒÃÇÖ¸¶¨ÊýÖµ×Ö¶ÎÖеÄÖµÊÇ·ñÓÐÕý¸ºÖ®·Ö»òÕßÓÃÁãÌî²¹¡£
¡¡¡¡±íÁгöÁ˸÷ÖÖÊýÖµÀàÐÍÒÔ¼°ËüÃǵÄÔÊÐí·¶Î§ºÍÕ¼ÓõÄÄÚ´æ¿Õ¼ä¡£
......
1.MySQL¼ò½é
MySQLÊÇÒ»¸ö¹ã·ºÊ¹ÓõĽṹ»¯²éѯÓïÑÔ£¨SQL£©Êý¾Ý¿â·þÎñÆ÷¡£ºÍÆäËûSQL·þÎñÆ÷Ò»Ñù£¬MySQLÌṩÁË·ÃÎʺ͹ÜÀíSQLÊý¾Ý¿âµÄ·½·¨£¬µ«ÊÇ£¬MySQLͬʱҲÌṩÁË´´½¨Êý¾Ý¿â½á¹¹ÒÔ¼°ÔÚÕâЩ½á¹¹ÖÐÌí¼Ó¡¢Ð޸ĺÍɾ³ýÕâЩ½á¹¹µÄ¹¤¾ß¡£
MySQLÊý¾Ý¿âÏà¹ØµÄÈí¼þ°üÖ÷ÒªÓÐÒÔϼ¸ÖÖ£º
......
Ê×Òª²½Öè(Ò»°ã¿ÉÊ¡ÂÔ):
¿ªÆômysql·þÎñ(ĬÈÏÊÇ¿ª»úʱ¾Í×Ô¶¯ÔËÐÐÁË):
¿ØÖÆÃæ°å
-->¹ÜÀí¹¤¾ß-->·þÎñ,ÔÚÀïÃæÕÒµ½Ãû³ÆΪmysqlµÄÏî,Ë«»÷¾Í¿É¿´ËüµÄ·þÎñ״̬ÊÇÆô¶¯»¹ÊÇÍ£Ö¹,°ÑËüÉèΪÆô¶¯
Á¬½Ómysql:
ÔÚÃüÁîÐÐÏÂÊäÈë mysql -h
localhost -u root -p»Ø³µ,È»ºóÊäÈëÃÜÂë¼´¿É;»òÖ±½ÓÔËÐÐmysql×Ô´øµÄÁ¬½Ó¹¤¾ß,È»ºóÊäÈëÃÜÂë¼ ......