现在的位置: 首页 > 综合 > 正文

随机调用数据库:不同的数据库中随机取数据的方法

2018年03月19日 ⁄ 综合 ⁄ 共 258字 ⁄ 字号 评论关闭

随机调用数据库:不同的数据库中随机取数据的方法

1、如果是SQL的话,可以用下面的方式

select top 10 * from table order by newid( )

2、如果是Oracle

select * from (
select * from table
order by dbms_random.value
)
where rownum <= 10;

3、如果是Access

SELECT top 10 * FROM table ORDER BY Rnd(id)

ID是自增长一个列

4、如果是MySQL

select * from table order by rand() limit 10

抱歉!评论已关闭.