Home Backend Development PHP Tutorial 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

Jul 13, 2016 am 10:51 AM
mysql content how extract database method solve question random



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 of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

Detailed tutorial on establishing a database connection using MySQLi in PHP

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

See all articles