Home > Database > Mysql Tutorial > body text

Mysql tutorial on using sql statements to add content after the original content

零下一度
Release: 2017-05-11 14:57:57
Original
1932 people have browsed it

This article mainly introduces the Mysql sql statement that maintains the existing content and adds content later. Friends who need it can refer to

The function of this command is to modify the data table ff_vod. 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

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 self variable 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 delimiter of 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. Free mysql online video tutorial

2. MySQL latest manual tutorial

3. Those things about database design

The above is the detailed content of Mysql tutorial on using sql statements to add content after the original content. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!