Home  >  Article  >  Database  >  Detailed explanation of how to use MySQL to generate random numbers and connect strings

Detailed explanation of how to use MySQL to generate random numbers and connect strings

巴扎黑
巴扎黑Original
2017-05-22 14:15:411654browse

This article mainly introduces the method of MySQL generating random numbers and connecting strings, briefly analyzes the related functions, and gives the corresponding SQL statement implementation method in the form of examples. Friends in need can refer to it

The example in this article describes the method of MySQL generating random numbers and concatenating strings. Share it with everyone for your reference, the details are as follows:

Method used:

concat('a','b','c'); Connecting characters String

rand(); Generate a random number

floor(); Take an integer

SQL statement example:

The code is as follows:

UPDATE user set reg_ip= concat(floor(RAND() * 250),'.',floor(RAND() * 250),'.',floor(RAND() * 250),'.',floor(RAND() * 250)) where username='xxx'

[Related recommendations]

1. Mysql free video tutorial

2. How to improve the speed of database query for millions of items

3. 5 common database design mistakes

4. How to keep Mysql running Based on the existing content, add content sql statements at the end

5. Summary of how to write commonly used SQL statements in MySQL

The above is the detailed content of Detailed explanation of how to use MySQL to generate random numbers and connect strings. For more information, please follow other related articles on the PHP Chinese website!

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