Jason
Jason

Reputation: 11363

Insert results from concatenated statement in a MySQL table

Given two fields in a table, how can I use the results of a CONCAT query to populate the results of a third column in the same table?

SELECT CONCAT (`field`, '-', `field2`) from `bgt_table` 

prints out the correct format, but how can I insert the results in the appropriate row?

Upvotes: 1

Views: 23

Answers (2)

Stephanie Gratzer
Stephanie Gratzer

Reputation: 304

UPDATE bgt_table SET field3 = CONCAT(field,'-',field2);

Upvotes: 1

John Woo
John Woo

Reputation: 263803

you need UPDATE

UPDATE bgt_table
SET thirdColumn = CONCAT (`field`, '-', `field2`)

Upvotes: 2

Related Questions