mysqlÊý¾Ý¿âlimit²éѯÓÅ»¯
mysqlÊý¾Ý¿âlimit²éѯÓÅ»¯
MYSQLµÄÓÅ»¯ÊǷdz£ÖØÒªµÄ¡£ÆäËû×î³£ÓÃÒ²×îÐèÒªÓÅ»¯µÄ¾ÍÊÇlimit¡£mysqlµÄlimit¸ø·ÖÒ³´øÀ´Á˼«´óµÄ·½±ã£¬µ«Êý¾ÝÁ¿Ò»´óµÄʱºò£¬limitµÄÐÔÄܾͼ±¾çϽµ¡£
ͬÑùÊÇÈ¡10ÌõÊý¾Ý
select * from yanxue8_visit limit 10000,10 ºÍ
select * from yanxue8_visit limit 0,10
¾Í²»ÊÇÒ»¸öÊýÁ¿¼¶±ðµÄ¡£
ÍøÉÏÒ²ºÜ¶à¹ØÓÚlimitµÄÎåÌõÓÅ»¯×¼Ôò£¬¶¼ÊÇ·Òë×ÔmysqlÊֲᣬËäÈ»ÕýÈ·µ«²»ÊµÓ᣽ñÌì·¢ÏÖһƪÎÄÕÂдÁËЩ¹ØÓÚlimitÓÅ»¯µÄ£¬ºÜ²»´í¡£
ÎÄÖв»ÊÇÖ±½ÓʹÓÃlimit£¬¶øÊÇÊ×ÏÈ»ñÈ¡µ½offsetµÄidÈ»ºóÖ±½ÓʹÓÃlimit sizeÀ´»ñÈ¡Êý¾Ý¡£¸ù¾ÝËûµÄÊý¾Ý£¬Ã÷ÏÔÒªºÃÓÚÖ±½ÓʹÓÃlimit¡£ÕâÀïÎÒ¾ßÌåʹÓÃÊý¾Ý·ÖÁ½ÖÖÇé¿ö½øÐвâÊÔ¡££¨²âÊÔ»·¾³win2033+p4Ë«ºË (3GHZ) +4GÄÚ´æ mysql 5.0.19£©
1¡¢offset±È½ÏСµÄʱºò¡£
select * from yanxue8_visit limit 10,10
¶à´ÎÔËÐУ¬Ê±¼ä±£³ÖÔÚ0.0004-0.0005Ö®¼ä
Select * from yanxue8_visit Where vid £¾=(
Select vid from yanxue8_visit Order By vid limit 10,1
) limit 10
¶à´ÎÔËÐУ¬Ê±¼ä±£³ÖÔÚ0.0005-0.0006Ö®¼ä£¬Ö÷ÒªÊÇ0.0006
½áÂÛ£ºÆ«ÒÆoffset½ÏСµÄʱºò£¬Ö±½ÓʹÓÃlimit½ÏÓÅ¡£Õâ¸öÏÔÈ»ÊÇ×Ó²éѯµÄÔÒò¡£
2¡¢offset´óµÄʱºò¡£
select * from yanxue8_visit limit 10000,10
¶à´ÎÔËÐУ¬Ê±¼ä±£³ÖÔÚ0.0187×óÓÒ
Select * from yanxue8_visit Where vid £¾=(
Select vid from yanxue8_visit Order By vid limit 10000,1
) limit 10
¶à´ÎÔËÐУ¬Ê±¼ä±£³ÖÔÚ0.0061×óÓÒ£¬Ö»ÓÐÇ°ÕßµÄ1/3¡£¿ÉÒÔÔ¤¼ÆoffsetÔ½´ó£¬ºóÕßÔ½ÓÅ¡£
ÒÔºóҪעÒâ¸ÄÕý×Ô¼ºµÄlimitÓï¾ä£¬ÓÅ»¯Ò»ÏÂmysqlÁË¡£
Ïà¹ØÎĵµ£º
1¡¢ÏÂÔØMySQLµÄLinux°²×°Îļþ
¡¡¡¡LinuxÏ°²×°MySQLÐèÒªÏÂÃæÁ½¸öÎļþ£º
¡¡¡¡MySQL-server-5.1.7-0.i386.rpm
¡¡¡¡ÏÂÔصØַΪ£ºhttp://dev.mysql.com/downloads/mysql/5.1.html£¬´ò¿ª´ËÍøÒ³£¬ÏÂÀÍøÒ³ÕÒµ½“Linux x86 generic RPM (statically linked against glibc 2.2.5) downloads”ÏÕÒµ½“Ser ......
ʾÀý£º
create procedure proc_name (in parameter integer)
begin
declare variable varchar(20);
if parameter=1 then
set variable='MySQL';
else
set variable='PHP';
end if;
insert into tb (name) values (variable);
end;
MySQLÀ©Õ¹Ò²ÊÇÖ§³Ö´æ´¢¹ý³ÌµÄ£¬²»¹ýÖ»Ö§³ÖÎÞ·µ»Ø½á¹ûµÄ´æ´¢¹ý³Ì
¿ÉÒÔÊ¹Ó ......
¹ØÓÚMySqlµÄµ¼Èëµ¼³öÎÊÌâ
ÔÚÖÕ¶ËÖУ¬½øÈëmysqlµÄ·¾¶ÏµÄbinÖУ¬ÔÚÕâ¸ö·¾¶Ï¿ÉÒÔÖ´ÐÐmysql£¬mysqldumpµÈÃüÁî¡£
»òÕßÌí¼Ó»·¾³±äÁ¿ ÉèÖû·¾³±äÁ¿path "...(mysqlµÄ°²×°Â·¾¶ÏµÄbinĿ¼)"£¬ÕâÑù¾Í²»±Øÿ´Î¶¼½øÈëÉÏÃæËù˵µÄ·¾¶Ï²Ù×÷¡£
µ¼³öÒ»¸ö¿â£º
mysqldump ......
select `a`.`id` AS `id`,`a`.`UserName` AS `UserName`,
(case when (`a`.`sRegDate` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`sRegDate`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `sRegDate`,(case when (`a`.`feeendtime` = _utf8'1990-01-01 00:00:00.0') then _ut ......