¹ØÓÚ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>
×¢Ò⣬Èç¹ûÊÇÁ¬½Óµ½ÁíÍâµÄ»úÆ÷ÉÏ£¬ÔòÐèÒª¼ÓÈëÒ»¸ö² ......
µÚÎåÕ ´úÂëÖØÓÃÓ뺯Êý±àд
require()»òinclude()¿ÉÒÔ½«Ò»¸öÎļþÔØÈëµ½php½Å±¾ÖС£
ÕâÁ½¸öº¯Êý¼¸ºõµÈ¼Û£¬Î¨Ò»µÄÇø±ðÊǵ÷ÓÃʧ°Üºórequire()¸ø³öÒ»¸öÖÂÃü´íÎ󣬶øinclude()Ö»¸ø³öÒ»¸ö¾¯¸æ¡£
Èç¹ûWebÒ³Ãæ¾ßÓÐÒ»ÖµÄÍâ¹Û£¬¿ÉÒÔ½«ÏàͬµÄ²¿·Ö·ÖÀëµ½µ¥¶ÀµÄÒ³ÃæÖУ¬È»ºó¿ÉÒÔÔÚphpÖÐʹÓÃrequire()Óï¾ä½«Ä£°åÔªËØ¼ÓÈëµ½Ò³ÃæÖС£
......
MYSQLÊý¾Ý¿âÖеij£ÓÃSQLÓï¾ä
1¡¢SELECT ²éѯÓï¾äºÍÌõ¼þÓï¾ä
SELECT ²éѯ×Ö¶Î from ±íÃû WHERE Ìõ¼þ
²éѯ×ֶΣº¿ÉÒÔʹÓÃͨÅä·û* ¡¢×Ö¶ÎÃû¡¢×ֶαðÃû
±íÃû£º Êý¾Ý¿â.±íÃû £¬±íÃû
³£ÓÃÌõ¼þ£º = µÈÓÚ ¡¢<>²»µÈÓÚ¡¢in °üº¬ ¡¢&nb ......