¹ØÓÚmysql µÄorder by rand()
¹Ù·½ÊÖ²áÉÏÊÇÕâôдµÄ£º
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:ËÎÌå;
mso-font-kerning:1.0pt;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
You cannot
use a column with RAND()
values in an ORDER BY clause, because ORDER BY would evaluate the column
multiple times. However, you can retrieve rows in random order like this:
mysql> SELECT
* from tbl_name
ORDER BY RAND();
ORDER BY
RAND() combined with LIMIT is useful for selecting a random sample from a set
of rows:
mysql> SELECT
* from table1, table2 WHERE a=b AND c<d
-> ORDER BY RAND() LIMIT 1000;
RAND()
is not meant to be a perfect random generator, but instead is a fast way to
generate ad hoc
random numbers which is portable between platforms for
the same MySQL ver
Ïà¹ØÎĵµ£º
MySQL ÃüÁîÐÐ
µÚÒ»ÕС¢mysql·þÎñµÄÆô¶¯ºÍÍ£Ö¹
net stop mysql
net start mysql
µÚ¶þÕС¢µÇ½mysql
Óï·¨ÈçÏ£º mysql -uÓû§Ãû -pÓû§ÃÜÂë
¼üÈëÃüÁîmysql -uroot -p£¬ »Ø³µºóÌáʾÄãÊäÈëÃÜÂ룬ÊäÈë12345£¬È»ºó»Ø³µ¼´¿É½øÈëµ½mysqlÖÐÁË£¬mysqlµÄÌáʾ·ûÊÇ£º
mysql>
×¢Ò⣬Èç¹ûÊÇÁ¬½Óµ½ÁíÍâµÄ»úÆ÷ÉÏ£¬ÔòÐèÒª¼ÓÈëÒ»¸ö² ......
ƽʱÎÒÃÇÔÚʹÓÃMySQLÊý¾Ý¿âµÄʱºò¾³£»áÒòΪ²Ù×÷ʧÎóÔì³ÉÊý¾Ý¶ªÊ§£¬MySQLÊý¾Ý¿â±¸·Ý¿ÉÒÔ°ïÖúÎÒÃDZÜÃâÓÉÓÚ¸÷ÖÖÔÒòÔì³ÉµÄÊý¾Ý¶ªÊ§»ò×ÅÊý¾Ý¿âµÄÆäËûÎÊÌâ¡£
¡¡¡¡Ò»¡¢Êý¾Ý±¸·Ý½Ý¾¶
¡¡¡¡ÒòΪÕâ¸ö·½·¨Ã»Óеõ½¹Ù·½ÕýʽÎĵµµÄÑéÖ¤£¬ÎÒÃÇÔݳÆÎªÊÔÑé°É¡£
¡¡¡¡Ä¿µÄ£º±¸·ÝhostAÖ÷»úÖÐÒ»¸öMySQLÊý¾Ý¿â±¸·ÝTestA£¬²¢»Ö¸´µ½µ½hostB»úÖÐ ......
תÌûÇë×¢Ã÷³ö´¦£¬²¢±£³ÖÎÄÕµÄÍêÕûÐÔ¡£
¶ÔMySQLÊý¾Ý¿âÀ´Ëµ£¬Í¬Ò»Ê±¿Ì£¬ÔÚͬһ¸öÁ¬½Ó£¨connection£©ÉÏ£¬Ö»ÔÊÐí½øÐÐÒ»¸ö²Ù×÷£¨query£¬etc.£©£¬Èç¹ûÄãµÄ³ÌÐòÊǶàÏ̵߳쬲¢ÇÒÄãÔÚ¶à¸öÏß³ÌÖж¼»áÀûÓÃͬһ¸öconnection¶ÔÊý¾Ý¿â½øÐвÙ×÷£¬ÄÇô£¬¾ÍÓпÉÄÜ·¢ÉúÎÊÌâ¡£
ÀýÈ磬Äã¿ÉÄÜ»áÊÕµ½“Commands out of sync”µÄ´íÎó ......
1¡¢phpÓëmysql½¨Á¢Á¬½Ó
php.ini ¼ÓÔØmysql×é¼þ
extension=php_mysql.dllǰµÄ;È¥µô
exetension_dir=""·¾¶ÊÇ·ñÕýÈ·
PhpÁ¬½Ómysqlº¯Êý
mysql_connect:¿ªÆôMYSQLÁ¬½Ó
mysql_select_dir:´ò¿ªÒ»¸öÊý¾Ý¿â
@ºÍor die Òþ²Ø´íÎóºÍÌõ¼þÏÔʾ
mysql_connect("Ö÷»ú","Óû§Ãû","ÃÜÂë");
mysql_sele ......
µØÖ·£º http://imysql.cn/taxonomy/term/1?page=1
[InnoDBϵÁÐ] -- innodb±íÈçºÎ¸ü¿ìµÃµ½count(*)½á¹û£ºhttp://imysql.cn/2008_06_24_speedup_innodb_count
[InnoDBϵÁÐϵÁÐ] -- ´óÊý¾ÝÁ¿µÄµ¼³öµ¼Èë·½·¨±È½Ï£º
http://imysql.cn/2007_10_15_large_innodb_table_export_import
[MySQLÓÅ»¯°¸Àý]ϵÁÐ -- DISABLE/ENABLE K ......