This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13936|Reply: 0

[Solved] mysql adds a value or string to the original value

[Copy link]
Posted on 4/20/2020 11:10:55 AM | | |

Update a field, add a value or string after it, and get this field value without querying the database How to add it?

user table, with two fields name [string] and age [int]

1. You need to add a unified logo in front of each name, such as: whh to user_whh

1. You need to add 5 years to each age, such as 20 to 25

Note!! Numbers can be directly connected with the '+' sign Strings must be concat, rules:(1)CONCAT(str1,str2,...)                       
#返回结果为将参数相连后得到的字符串. If any of the parameters are NULL, the return value is NULL. Perhaps there is one or more parameters.
#如果所有参数均为非二进制字符串, the result is a non-binary string. If the argument contains either binary string, the result is a binary string.
#一个数字参数被转化为与之相等的二进制字符串格式; To avoid this, you can use explicit types.
(2)CONCAT_WS()
#UPDATE user set name=CONCAT_WS('_','user',name)
#字段原值为:jack will output a user_jack, note that the first parameter is a connector.







Previous:MSSQL Trusted_Connection configuration
Next:How to use RelativeSource binding in WPF
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com