SQL statement used to copy data of two fields in a database table
Today, I want to add a new field to the table, but want to be the same as the value of another field in the Table. Because I want to implement the data through SQL statements, the following sentence is really useful after testing.
Copy codeThe Code is as follows: update jb51_temp set B =
Jb51_temp indicates that A has a value field, and B is A newly added field. Remember to put the null value table in front of it. If set a = B, all your values are empty, which makes it troublesome, we recommend that you back up the database before the operation.
How to copy a field value to another field
For example, there are two fields A and B. The value of field A is "me" and the value of field B is "us". How to copy the value of field B to field A using the update statement, and the combination with A should be placed behind the original content. after the update, field A should be "we" and field B will not change.
Copy codeThe Code is as follows: update table set A = A + B