zoukankan      html  css  js  c++  java
  • 数据库读取随机几条记录的SQL语句

    以下示例从表[tableName]中读取10条随机记录的SQL语句

    1 Access

        select top 10 *  from [tableName] order by rnd(id)
        select top 10 *  from [tableName] where [cond] order by rnd(id)

        注:id是自增长类型的主键

    2 SQL Server

        select Top 10 * From [tableName] order By NewID()

    另外:还有种方法:先获取总记录数,然后取1~总数之间的随机数,rs.move,不过这种方法有点罗嗦,在此不推荐。

    3 MySQL

        select * From [tableName] Order By rand() Limit 10
  • 相关阅读:
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    测试面试总结02
    测试出的缺陷(bug)
    测试用例的内容
    微信发红包测试要点
  • 原文地址:https://www.cnblogs.com/lear/p/2009995.html
Copyright © 2011-2022 走看看