关于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
相关文档:
仅仅是看一些书是零零散散记下的,给自己备忘而已。建议去看专业网站的笔记。
1.主键的值必须是唯一的,并且不能为空,这可以提高MySQL从多个表中取得数据或者取得指定键值对应的行的速度。MySQL通过一个特殊的称为Index索引的数据结构做到这一点,Index是找到一条记录的快捷方式,就像图书馆的卡片目录。
2.查看表的列定 ......
在网上找了很多IIS+PHP的配置的方法,试过之后很多都不能达到效果。于是总结了大部分的文章后就得出了这样的方法:(本次操作系统以Win2000为例,如果你要改为其它系统就把系统根目录变一下就Ok了)
一、下载必须的程序:
(1) 先到PHP的官方网站下载一个PHP(本文就以PHP 4.4.2为例)。 ......
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 ......
mysql 创建表:
mysql> create table user(
-> userid int(4) primary key not null auto_increment,
-> username varchar(16) not null,
-> userpassword varchar(32) not null
-> );
create table log(
logid int(4) ......