首頁 >資料庫 >mysql教程 >mysql 中如何随机提取数据库记录_MySQL

mysql 中如何随机提取数据库记录_MySQL

WBOY
WBOY原創
2016-06-01 13:59:271161瀏覽

   帮朋友改个asp的相关产品显示要用到随机读取当前类别的前10个产品,Google了下收藏的
  mysql中随机提取数据库记录

  -------------------------------------------------------------------------------- view plaincopy to clipboardprint?

  select * from tablename order by rand() limit 10

  select * from tablename order by rand() limit 10sqlserver中随机提取数据库记录

  -------------------------------------------------------------------------------- view plaincopy to clipboardprint?

  select top 10 * from tablename order by NEWID()

  select top 10 * from tablename order by NEWID()Access中随机提取数据库记录

  -------------------------------------------------------------------------------- view plaincopy to clipboardprint?

  SELECT top 10 * FROM tablename ORDER BY Rnd(FId)

  SELECT top 10 * FROM tablename ORDER BY Rnd(FId)FId:为你当前表的ID字段名

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn