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"
ΪʲôÓеÄÅóÓÑжÔز»ÁËÄØ,ÒòΪËûÒѾ°ÑÔ´Îļþ¶¼É¾³ýÁË »òÕßÔËÐÐÐ ......
Ò»¡¢³£ÓÃ×Ö·û´®º¯Êý
1.CONCAT(str1,str2,...)
mysql> ? concat;
mysql> SELECT CONCAT('My', 'S', 'QL');
+-------------------------+
| CONCAT('My', 'S', 'QL') |
+-------------------------+
| MySQL ......
1.Í£µômysqld
service mysqld stop
2.ÖØÆômysqld£¬Ö¸¶¨²ÎÊý
service mysqld start --skip-networking --skip-grant-tables
»òÕß
/opt/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables &
/opt/mysql/ÊÇÎÒµÄMYSQL°²×°Â·¾¶
skip-grant-tables:Á¬½ÓʱÌø¹ýÊ ......
1.MySQL¼ò½é
MySQLÊÇÒ»¸ö¹ã·ºÊ¹ÓõĽṹ»¯²éѯÓïÑÔ£¨SQL£©Êý¾Ý¿â·þÎñÆ÷¡£ºÍÆäËûSQL·þÎñÆ÷Ò»Ñù£¬MySQLÌṩÁË·ÃÎʺ͹ÜÀíSQLÊý¾Ý¿âµÄ·½·¨£¬µ«ÊÇ£¬MySQLͬʱҲÌṩÁË´´½¨Êý¾Ý¿â½á¹¹ÒÔ¼°ÔÚÕâЩ½á¹¹ÖÐÌí¼Ó¡¢Ð޸ĺÍɾ³ýÕâЩ½á¹¹µÄ¹¤¾ß¡£
MySQLÊý¾Ý¿âÏà¹ØµÄÈí¼þ°üÖ÷ÒªÓÐÒÔϼ¸ÖÖ£º
......