0

How do add the concatenated firstname column and lastname column from a table with 100 rows and then add it fullname column each of the concatenated first name and last name

I tried:

INSERT INTO `table1` (`fullname`) VALUES (CONCAT(first_name,last_name))

What it did is that it added a new row with nothing in it it didn't add each row of 100. What I want is that for each of the rows of first and last name there is a fullname that is concatenated.

4

2 回答 2

1

You're looking to do an UPDATE:

UPDATE `table1` SET `fullname` = CONCAT(first_name,last_name)

Assuming that you've already added the column:

ALTER TABLE `table1` ADD `fullname` VARCHAR(60)
于 2013-04-01T21:19:22.947 回答
1

我猜你想让它可读,所以你的查询应该是这样的:

UPDATE `table1` SET `fullname` = CONCAT(first_name, ' ', last_name)

如果没有带有空格的中心引号,它将是“first_namelast_name”而不是“first_name last_name”

于 2013-04-01T22:59:36.540 回答