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)
MyODBC
MyODBC 2.50 Local database:
"Driver={mySQL};Server=localhost;Option=16834;Database=mydatabase;"
MyODBC 2.50 Remote database:
"Driver={mySQL};Server=data.domain.com;Port=3306;Option=131072;Stmt=;Database=my-databa ......
Chapter 4. Indexes
Ë÷ÒýÓÐÖúÓÚMySQLÔÚºÆÈçÑ̺£µÄÊý¾ÝÖÐѸËÙÕÒµ½ºÍÈ¡µÃÕýÈ·µÄ¼Ç¼¡£
4.1 Indexing Basics
4.1.1 Index Concepts
Ë÷ÒýÊÇ°´ÕÕijÖÖ¹æÔòÅÅÐòµÄ¡£Ë÷ÒýÒ²¾ÍÊÇÎþÉüһЩ¿Õ¼äºÍcpuµÄ¿ªÏúÀ´Ê¹ÄãµÄ²éѯÅܵøü¿ìµã¡£ÁíÍâÌáÐѵÄÊÇ£¬¶ÔÓÚMySQLÀ´½²£¬ÊõÓï“Key”ºÍ“Index”ÊÇ¿ÉÒÔ»¥ÏàÌæ»»µÄ¡£
4. ......
Ò»¡¢³£ÓÃ×Ö·û´®º¯Êý
1.CONCAT(str1,str2,...)
mysql> ? concat;
mysql> SELECT CONCAT('My', 'S', 'QL');
+-------------------------+
| CONCAT('My', 'S', 'QL') |
+-------------------------+
| MySQL ......
http://javeye.javaeye.com/blog/558093
ÎÒÃÇÖªµÀ£¬group by¿ÉÒÔ½«sql²éѯ½á¹û°´ÕÕgroup byºóÃæÁнøÐзÖÀàÏÔʾ¡£±ÈÈ磺
Sql´úÂë
select
columnA,columnB
from
table
group
by
columnA,columnB
select columnA,columnB from table group by columnA,colum ......
Ê×Òª²½Öè(Ò»°ã¿ÉÊ¡ÂÔ):
¿ªÆômysql·þÎñ(ĬÈÏÊÇ¿ª»úʱ¾Í×Ô¶¯ÔËÐÐÁË):
¿ØÖÆÃæ°å
-->¹ÜÀí¹¤¾ß-->·þÎñ,ÔÚÀïÃæÕÒµ½Ãû³ÆΪmysqlµÄÏî,Ë«»÷¾Í¿É¿´ËüµÄ·þÎñ״̬ÊÇÆô¶¯»¹ÊÇÍ£Ö¹,°ÑËüÉèΪÆô¶¯
Á¬½Ómysql:
ÔÚÃüÁîÐÐÏÂÊäÈë mysql -h
localhost -u root -p»Ø³µ,È»ºóÊäÈëÃÜÂë¼´¿É;»òÖ±½ÓÔËÐÐmysql×Ô´øµÄÁ¬½Ó¹¤¾ß,È»ºóÊäÈëÃÜÂë¼ ......