Home  >  Article  >  Backend Development  >  How to randomly extract 10 items from the database in mysql? _PHP Tutorial

How to randomly extract 10 items from the database in mysql? _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:51:011199browse



Question
How to randomly extract 10 pieces of content from the database?
Solution
Is there any good solution that is efficient and simple?


Reference answer
If you have a caching system....load directly from cache....
Reference answer
No~
Reference answer
random syntax...
Reference answer
Why not use Rand function
Reference answer
Rand must be used, but I don’t know how to write this SQL statement
Reference answer
SELECT ... FROM ... WHERE ... ORDER BY RAND() LIMIT 10


Copy code
Reference answer
Original post by Fising on 2009-1-4 11:54 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=814691&ptid=100356]Link tag [img]http://bbs. 111cn.cn/images/common/back.gif[/img][/url]
SELECT ... FROM ... WHERE ... ORDER BY RAND() LIMIT 10
Learning
Reference answer
Thank you. I wrote it like this just now, but the prompt statement is wrong. Does rand have to be capitalized? I just lowercase it, wrong.
Reference answer
[url=http://www.linvo2008.cn/blog/?p=7]Link tag http://www.linvo2008.cn/blog/?p=7[/url]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632599.htmlTechArticleQuestion: How to randomly extract 10 pieces of content from the database? Solution Is there a good solution that is efficient and simple? Reference answer If you have a cache system... directly from the cache...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn