Combine Two mysql columns and one mysql Column
For example, if there are two columns: surname and name, the query result is one column. The concat keyword is required. The SQL statement is as follows:
select concat(firstName,lastName) from tj_user
Merge two mysql Columns
Use the following SQL statement to delete the Adress2 column:
Update Adress set Adress1 = concate (Adress1, Adress2)
How to add a column between two columns in mysql
Mysql> create table testtable (
-> A int default 0,
-> B INT DEFAULT 0
->) ENGINE = innodb default charset = UTF8;
Query OK, 0 rows affected
Mysql> desc testtable;
+ ------- + --------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ------- + --------- + ------ + ----- + --------- + ------- +
| A | int (11) | YES | 0 |
| B | int (11) | YES | 0 |
+ ------- + --------- + ------ + ----- + --------- + ------- +
2 rows in set
Mysql> alter table testtable add column c int default 0 after;
Query OK, 0 rows affected
Records: 0 Duplicates: 0 Warnings: 0
Mysql> desc testtable;
+ ------- + --------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ------- + --------- + ------ + ----- + --------- + ------- +
| A | int (11) | YES | 0 |
| C | int (11) | YES | 0 |
| B | int (11) | YES | 0 |
+ ------- + --------- + ------ + ----- + --------- + ------- +
3 rows in set