Home > Database > Mysql Tutorial > Detailed explanation of the SQL statement that does not change the original content of Mysql and adds content later

Detailed explanation of the SQL statement that does not change the original content of Mysql and adds content later

巴扎黑
Release: 2017-05-22 14:11:45
Original
2090 people have browsed it

This article mainly introduces the sql statement of Mysql to maintain the existing content and add content later. Friends who need it can refer to

The function of this command is to modify the data table ff_vod and add 999999999 after the vod_url field content. .

update ff_vod set vod_url=CONCAT(vod_url,'999999999') where vod_id BETWEEN 1 AND 42553
Copy after login

The following statement is used to modify only the content with vod_id 1-42553.

where vod_id BETWEEN 1 AND 42553
Copy after login

Script House editor’s analysis:

In fact, this mainly uses the CONCAT function. The mysql CONCAT() function is used to connect multiple strings into one string.

The following will take you to understand the mysql CONCAT() function

mysql CONCAT() function is used to concatenate multiple strings into one string, which is the most important One of the mysql functions, the mysql CONCAT() function will be introduced in detail for your reference below

mysql CONCAT(str1,str2,…)                        
The return result is the string generated by the connection parameter. If any parameter is NULL, the return value is NULL. There may be one or more parameters. If all arguments are non-binary strings, the result is a non-binary string. If the argument contains any binary string, the result is a binary string. A numeric argument is converted to its equivalent binary string format; to avoid this, use an explicit type cast, for example: SELECT CONCAT(CAST(int_col AS CHAR), char_col)

mysql> SELECT CONCAT('My', ‘S', ‘QL');
-> ‘MySQL'
mysql> SELECT CONCAT('My', NULL, ‘QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> ‘14.3′
Copy after login

mysql CONCAT_WS(separator,str1,str2,…)
CONCAT_WS() represents CONCAT With Separator and is a special form of CONCAT(). The first parameter is the separator for other parameters. The position of the delimiter is placed between the two strings to be concatenated. The delimiter can be a string or other parameters. If the delimiter is NULL, the result is NULL. The function ignores NULL values ​​after any delimiter argument.

mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name');
-> ‘First name,Second name,Last Name'
mysql> SELECT CONCAT_WS(',','First name',NULL,'Last Name');
-> ‘First name,Last Name'
Copy after login

mysql CONCAT_WS() will not ignore any empty string. (However, all NULLs are ignored).

【Related recommendations】

1. Mysql free video tutorial

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

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

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

5. 5 Common Database Design Mistakes

The above is the detailed content of Detailed explanation of the SQL statement that does not change the original content of Mysql and adds content later. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template