Home >Backend Development >PHP Tutorial >How to randomly extract 10 items from the database in mysql? _PHP Tutorial
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]