分类: 数据库开发技术
2009-05-08 22:13:47
先将从数据库随机取n条记录的指令总结如下,供以后查考.
(1) ACCESS:
SELECT TOP n * FROM [tablename] {WHRER condition} ORDER BY
RND(field_name) {ASC/DESC}
(2) SQL SERVER:
SELECT TOP n * FROM [tablename] {WHRER condition} ORDER
BY NEWID() {ASC/DESC}
(3) MYSQL:
SELECT * FROM [tablename] ORDER BY RAND() {ASC/DESC} LIMIT
n
(4) ORACLE:
SELECT * FROM (SELECT * FROM [tablename] ORDER BY
DBMS_RANDOM.VALUE) temp WHERE rownum <= n