关于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.查看表的列定 ......
MYSQL数据库中的常用SQL语句
1、SELECT 查询语句和条件语句
SELECT 查询字段 from 表名 WHERE 条件
查询字段:可以使用通配符* 、字段名、字段别名
表名: 数据库.表名 ,表名
常用条件: = 等于 、<>不等于、in 包含 、&nb ......
一、MySql简介概要
MySQL是一个小型关系型数据库管理系统,开发者为瑞典MySQL AB公司,后来
被Sun公司收购,现在正在被甲骨文收购,支持FreeBSD、Linux、MAC、Windows
等多种操作系统 与其他的大型数据库例如Oracle、DB2、SQL Server等相比功能稍弱
一些 题外话:Postgresql&n ......
Memcached Functions for MYSQL官方主页:
https://launchpad.net/memcached-udfs
两篇基本文章:
http://www.libing.name/2009/02/06/mysql-map-data-to-memcached.html
http://www.libing.name/2008/02/26/mysql-map-memcached.html
安装和验证的SQL语句:
http://hg.tangent.org/memcached_functions_mysql/file/7 ......