|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is there a way to update a table so that a column's values can be changed to a concatenation of two other column values? For instance, something like ...
UPDATE TABLE tablename SET colA = colB.colC; |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Kebbel, John wrote:
> Is there a way to update a table so that a column's values can be changed to a concatenation of two other column values? For instance, something like ... > > UPDATE TABLE tablename SET colA = colB.colC; > > > > > > Is this what you're looking for? mysql> create table concattest ( -> field1 varchar(25), -> field2 varchar(25), -> field3 varchar(25) -> ); Query OK, 0 rows affected (0.07 sec) mysql> insert into concattest (field2, field3) values ('hi', 'there'); Query OK, 1 row affected (0.00 sec) mysql> select * from concattest; +--------+--------+--------+ | field1 | field2 | field3 | +--------+--------+--------+ | NULL | hi | there | +--------+--------+--------+ 1 row in set (0.00 sec) mysql> update concattest set field1 = concat(field2, field3); Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from concattest; +---------+--------+--------+ | field1 | field2 | field3 | +---------+--------+--------+ | hithere | hi | there | +---------+--------+--------+ 1 row in set (0.00 sec) |
|
![]() |
| Outils de la discussion | |
|
|