ÆäËûÊý¾Ý¿âÄ£ÄâʵÏÖmysqlµÄlimitÓï·¨
¼ÙÈçÎÒÓиöuser±í,ÎÒÏë²éѯ·ûºÏijЩÌõ¼þµÄµÚ50¸öÓû§¿ªÊ¼µÄ10¸öÓû§,ÇÒ²»ÄÜʹÓÃidºÅbetween andÄÇÑù²éѯ,Ó¦¸ÃÔõôдSQLÓï¾ä?
¡¡¡¡ÔÚmysqlÊý¾Ý¿âÖÐÓÐlimit,offsetÓï¾ä¿ÉÒÔ·½±ãµÄʵÏÖ,ÄÇôÔÚSQL serverÖÐÄØ?SQL ServerÊÇ·ñÖ§³ÖlimitºÍoffsetÓï¾äÄØ?
select top 10 * from
(select top 60 * from [user] order by userid) aa
order by userid desc
¡¡¡¡oracle,Èç¹ûÏë´Ó±íÖÐÈ¡³ö°´ÕÕij×Ö¶ÎÅÅÐòÇ°Mµ½NÌõ¼Ç¼
¡¡¡¡ÏÂÃæµÄORACLEÓï¾äÊÇ×îºÃµÄ:
SQL> select ID from
(
select ID , rownum as con from
(
select ID from TestSort order by ID
)
where rownum <= 3 /*NÖµ*/
)
where con >= 2; /*M Öµ*/
ID
----------
2
3
Ïà¹ØÎĵµ£º
Ê×ÏÈÐèÒª²é¿´Ò»Ï´´½¨º¯ÊýµÄ¹¦ÄÜÊÇ·ñ¿ªÆô£º
X:\proper\mysql\bin>mysql -h localhost -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.0.22-community-nt-log
Type 'help;' or '\h' for help. Type ' ......
MySql°æ±¾£ºmysql-noinstall-5.1.43-win32
ϵͳ£ºVista
ÔÚC:\myProgram Files\mysql-5.1.43-win32£¨½âѹµÄĿ¼£©Ï½«Ñ¡Ò»¸öÅäÖÃÎļþ£¨my-small.ini£©±à¼£º
1.ÔÚ[client]ÏÂÌí¼Ó£º
default-character-set=utf8 ......
ÀýÈ磬MySQLĬÈϵÄÊý¾ÝÎļþ´æ´¢Ä¿Â¼Îª/var/lib/mysql¡£¼ÙÈçÒª°ÑĿ¼ÒƵ½/home/dataÏÂÐèÒª½øÐÐÏÂÃ漸²½£º
1¡¢homeĿ¼Ï½¨Á¢dataĿ¼
cd /home
mkdir data
2¡¢°ÑMySQL·þÎñ½ø³ÌÍ£µô£º
......
£¨1£©Æô¶¯
MySQL°²×°Íê³ÉºóÆô¶¯ÎļþmysqlÔÚ/etc/init.dĿ¼Ï£¬ÔÚÐèÒªÆô¶¯MySQL·þÎñʱÔËÐÐÏÂÃæÃüÁî¼´¿É¡£ [root@test1 init.d]# /etc/init.d/mysql start
£¨2£©Í£Ö¹
/usr/bin/mysqladmin -u root -p shutdown
£¨3£©ÉèÖÃMySQL×Ô¶¯Æô¶¯
1£©²ì¿´mysqlÊÇ·ñÔÚ×Ô¶ ......
¡¡¡¡1006£ºMYSQL ´´½¨Êý¾Ý¿âʧ°Ü ......