In some scenarios, we need to modify our varchar type fields, and the result of the modification is the concatenation of two fields or the concatenation of a field + a string. As shown below, we want to modify the name in the xx_role table to name+id. In MySQL, if we operate directly through "+", an error will be prompted. The operator "+" is used to add numbers. Here, the keyword concat is needed to indicate concatenation. Similarly, we can also use field + string to concatenate. Here we will briefly talk about the "+" operation, which is used to add numeric fields, as shown below: Supplement: Use update in mysql to update multiple fields at the same time, including select query Wrong attempts:update table name set (field 1, field 2, field 3, ...) = (select value 1, value 2, value 3, ...) where condition Correct way:# UPDATE OldData o, NewData n without using select SET o.name = n.name, o.address = n.address where n.nid=234 and o.id=123; # Using select situation UPDATE OldData o, (select name, address from NewData where id = 123) n SET o.name = n.name, o.address = n.address where n.nid=234; The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: 15 lines of CSS code can cause Apple devices to crash, and the latest iOS 12 is not immune
>>: How to enable remote access in Docker
This article shares the specific steps of install...
Table of contents Determine whether a record alre...
This article example shares the specific code of ...
Relative Length Units em Description: Relative len...
Quick Reading Why do we need to monitor SQL state...
Software Version Windows: Windows 10 MySQL: mysql...
This article example shares the specific code of ...
Write a SQL first SELECT DISTINCT from_id FROM co...
This article shares the specific code of Vue to s...
Optimistic Locking Optimistic locking is mostly i...
Empty link: That is, there is no link with a targ...
The <script> tag In HTML5, script has the f...
Table of contents Basic usage of Promise: 1. Crea...
I have written an article about mobile adaptation...
Table of contents iview-admin2.0 built-in permiss...