How to implement MySQL random query data with MySQL random update data?

Source: Internet
Author: User

The following article mainly introduces the MySQL random selection of data, the implementation of MYSQ random query data and MYSQ random update data of the actual operation of the description, and the actual operation of the statement to be used in the description, the following is a description of its specific operation steps.

MySQL Random query data

I used to discuss this problem in the group. MySQL's syntax is fun. They used to want to use PHP to implement random, but take out more than two times like to make more than one query. Turn the manual, find the following statement, you can complete the task.

    1. SELECT *  from ORDER  by Rand 5

The rand () function in MySQL says so in the manual:

  

    RAND ()      RAND

Returns a random floating-point value within a range of 0 to 1.0. If an integer parameter n is specified, it is used as the seed value.

For the efficiency of the rand () function in MySQL, you can refer to "MySQL Order by Rand () efficiency": http://www.phpq.net/mysql/mysql-order-by-rand.html

Actual effect

  

Mysql> Select RAND();  - 0.5925MySQL> Select RAND( -);  - 0.1811MySQL> Select RAND( -);  - 0.1811MySQL> Select RAND();  - 0.2079MySQL> Select RAND();  - 0.7888 

MySQL Random update data

How to write a statement can update hundreds of MySQL data!

Need to test MySQL database, there is a database of tens of thousands of data, how to write a PHP file every time the update hundreds of information, I am writing a loop to update a message, so I know with while write can be, if a

Update is like 100 data changes how to write it?

The correct answer is:

    1. UPDATE SET = Rand ();


Air dead in the Insert command, value () inside with Rand (), notice that the field width is enough to always think that MySQL randomly query a few data, use

    1. SELECT *  from 'tableORDERbyRAND5

You can do it. The above related content is to implement MYSQ random query data, MYSQ random update data Introduction, hope you can have some gains.

How to implement MySQL random query data with MySQL random update data?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.