Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mysql ʹÓÃrandËæ»ú²éѯ¼Ç¼ЧÂʲâÊÔ

Ò»Ö±ÒÔΪmysqlËæ»ú²éѯ¼¸ÌõÊý¾Ý£¬¾ÍÓÃ
SELECT
 
*
 
from
 `
table

ORDER
 
BY
 
RAND
() LIMIT 
5
¾Í¿ÉÒÔÁË¡£
µ«ÊÇÕæÕý²âÊÔһϲŷ¢ÏÖÕâÑùЧÂʷdz£µÍ¡£Ò»¸ö15ÍòÓàÌõµÄ¿â£¬²éѯ5ÌõÊý¾Ý£¬¾ÓȻҪ8ÃëÒÔÉÏ
²é¿´¹Ù·½ÊֲᣬҲ˵rand()·ÅÔÚORDER BY ×Ó¾äÖлᱻִÐжà´Î£¬×ÔȻЧÂʼ°ºÜµÍ¡£
You cannot use a column with RAND() values in an ORDER BY clause,
because ORDER BY would evaluate the column multiple times.
ËÑË÷Google£¬ÍøÉÏ»ù±¾É϶¼ÊDzéѯmax(id) * rand()À´Ëæ»ú»ñÈ¡Êý¾Ý¡£
SELECT
 
*
 
from
 `
table

AS
 t1 
JOIN
 (
SELECT
 
ROUND
(
RAND
() 
*
 (
SELECT
 
MAX
(id) 
from
 `
table
`)) 
AS
 id) 
AS
 t2 
WHERE
 t1.id 
>=
 t2.id 
ORDER
 
BY
 t1.id 
ASC
 LIMIT 
5
;
µ«ÊÇÕâÑù»á²úÉúÁ¬ÐøµÄ5Ìõ¼Ç¼¡£½â¾ö°ì·¨Ö»ÄÜÊÇÿ´Î²éѯһÌõ£¬²éѯ5´Î¡£¼´±ãÈç´ËÒ²ÖµµÃ£¬ÒòΪ15ÍòÌõµÄ±í£¬²éѯֻÐèÒª0.01Ãë²»µ½¡£
ÉÏÃæµÄÓï¾ä²ÉÓõÄÊÇJOIN£¬mysqlµÄÂÛ̳ÉÏÓÐÈËʹÓÃ
SELECT
 
*
 
from
 `
table

WHERE
 id 
>=
 (
SELECT
 
FLOOR

MAX
(id) 
*
 
RAND
()) 
from
 `
table
` ) 
ORDER
 
BY
 id LIMIT 
1
;
ÎÒ²âÊÔÁËһϣ¬ÐèÒª0.5Ã룬ËÙ¶ÈÒ²²»´í£¬µ«ÊǸúÉÏÃæµÄÓï¾ä»¹ÊÇÓкܴó²î¾à¡£×ܾõÓÐʲôµØ·½²»Õý³£¡£
ÓÚÊÇÎÒ°ÑÓï¾ä¸ÄдÁËһϡ£
SELECT
 
*
 
from
 `
table

WHERE
 id 
>=
 (
SELECT
 
floor
(
RAND
() 
*
 (
SELECT
 
MAX
(id) 
from
 `
table
`)))  
ORDER
 
BY
 id LIMIT 
1
;
ÕâÏ£¬Ð§ÂÊÓÖÌá¸ßÁË£¬²éѯʱ¼äÖ»ÓÐ0.01Ãë
×îºó£¬ÔÙ°ÑÓï¾äÍêÉÆһϣ¬¼ÓÉÏMIN(id)µÄÅжϡ£ÎÒÔÚ×ʼ²âÊÔµÄʱºò£¬¾ÍÊÇÒòΪûÓмÓÉÏMIN(id)µÄÅжϣ¬½á¹ûÓÐÒ»°ëµÄʱ¼ä×ÜÊDzéѯµ½±í
ÖеÄÇ°Ã漸ÐС£
ÍêÕû²éѯÓï¾äÊÇ£º
SELECT
 
*
 
from
 `
table

WHERE
 id 
&g


Ïà¹ØÎĵµ£º

QtÊý¾Ý¿â£¨¶þ£©Ìí¼ÓMySQLÊý¾Ý¿âÇý¶¯²å¼þ


±¾ÎÄÕÂÔ­´´ÓÚwww.yafeilinux.com ×ªÔØÇë×¢Ã÷³ö´¦¡£
ÔÚÉÏÒ»½ÚµÄĩβÎÒÃÇÒѾ­¿´µ½£¬ÏÖÔÚ¿ÉÓõÄÊý¾Ý¿âÇý¶¯Ö»ÓÐ3ÖÖ£¬ÄÇôÔõÑùʹÓÃÆäËûµÄÊý¾Ý¿âÄØ£¿ÔÚQtÖУ¬ÎÒÃÇÐèÒª×Ô¼º±àÒëÆäËûÊý¾Ý¿âÇý¶¯µÄ´úÂ룬ÈÃËüÃÇÒÔ²å¼þµÄÐÎʽÀ´Ê¹Óá£ÏÂÃæÎÒÃǾÍÒÔÏÖÔڱȽÏÁ÷ÐеÄMySQLÊý¾Ý¿âΪÀý£¬ËµÃ÷Ò»ÏÂÔõÑùÔÚQt CreatorÖÐÌí¼ÓÊý¾Ý¿âÇý¶¯²å¼þ ......

MySQL³£ÓÃÃüÁî

µÚÒ»ÕС¢mysql·þÎñµÄÆô¶¯ºÍÍ£Ö¹
net stop mysql
net start mysql
µÚ¶þÕС¢µÇ½mysql
Óï·¨ÈçÏ£º mysql -uÓû§Ãû -pÓû§ÃÜÂë
¼üÈëÃüÁîmysql -uroot -p£¬ »Ø³µºóÌáʾÄãÊäÈëÃÜÂ룬ÊäÈë12345£¬È»ºó»Ø³µ¼´¿É½øÈëµ½mysqlÖÐÁË£¬mysqlµÄÌáʾ·ûÊÇ£º
mysql>
×¢Ò⣬Èç¹ûÊÇÁ¬½Óµ½ÁíÍâµÄ»úÆ÷ÉÏ£¬ÔòÐèÒª¼ÓÈëÒ»¸ö²ÎÊý-h»úÆ÷IP
µ ......

MySqlÃüÁî´óÈ«

1. Á¬½Ómysql:
mysqlbinmysql -hÖ÷»úµØÖ· -u Óû§Ãû £­p Óû§ÃÜÂë
2.Í˳ömysql:exit
3. ÐÞ¸ÄÃÜÂë:
mysqlbinmysqladmin -uroot -p(oldpassword) password newpassword
4.Ôö¼ÓÓû§£º
Ìí¼ÓÒ»¸öÓû§test1 ÃÜÂëΪABC£»ÈÃËû¿ÉÒÔÔÚÈκÎÖ÷»úÉϵǼ,²¢¶ÔËùÓÐÊý¾Ý¿âÓвéѯ¡¢²åÈë¡¢Ð޸ġ¢É¾³ýµÄȨÏÞ¡£Ê×ÏÈÓÃÒÔrootÓû§Á¬Èë
mysq ......

Linux Ô´Âë°²×°Mysql5.5

¹«Ë¾µÄ·þÎñÆ÷ÊÇCentOS 5.4(Final)°æµÄ£¬½ñÌìÔÚÉÏÃæ°²×°ÁËÒ»»Ømysql5.5£¬¼Ç¼ÈçÏ£º
1¡¢´Óhttp://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.2-m2.tar.gz ÏÂÔØÔ´Âë°²×°°üµ½/usr/local/src
2¡¢tar zxvf mysql-5.5.2-m2.tar.gz ½âѹµ½/usr/local/src/mysql-5.5.2-m2ÏÂ
    cd mysql-5.5.2-m2/
&n ......

Apache+Mysql+Php°²×°Îĵµ(rpm°æ±¾)

¡¡¡¡1.mysql
¡¡¡¡ÔÚÈçÏÂÒ³ÃæÏÂÔØmysqlµÄfor linux rpm°ü
¡¡¡¡¡¡http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
¡¡¡¡¡¡http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
¡¡¡¡´æÖÁ/home/tmpĿ¼
¡¡¡¡ÃüÁîÁÐ±í£º¡¡
¡¡¡¡cd /home/tmp
¡¡¡¡rpm -ivh MySQL-3.23.52-1.i386.rpm #°²×°mysql serv ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ