How to update column text value with concatenation of multiple columns text values?


Problem :

For e.g. my table structure is like

id(int, auto_increment), 
first_name(text), 
last_name(text), 
address(text), 
merged_content(text)

I have thousands of rows which have first_name, last_name and address entries already filled. I want to update concatenated text in merged_content. I know, how to do this in PHP, but updating thousands of records (apprx 30K) is very time consuming.

So, I was hoping if something like this can be achieved in MySql directly -

Update table_x set merged_content="<p>" + first_name + " " + last_name + "</p><p><b>Address -</b> " + address + "</p>"

Obviously the above query is wrong, and not working, but I couldn't even find anything else, that I could try.



Solution :

Mysql has built-in function called concat which you can use, something as

Update table_x 
set 
merged_content=
concat('<p>',first_name,' ',last_name,'</p><p><b>Address -</b> ',address,'</p>'); 

Mysql Tutorials

Mysql Howto..

How to not include blank fields when updating a MySQL record

How to replace escape character with a string

How to enforce constraints in mysql

How to get the contents of multiple dynamic text files and store it in one text file and in mysql - Python 2.7?

How to copy text column value from one row to another row in mySQL

How to insert data from MySQL into an array to then be displayed on a bar graph in Netbeans?

How to use group by <> properly in MySQL?

SQL - How to create a new relation between tables A & C based on an existing relationship between A & B - en mass?

how to round mysql column in a table output

time in array - how to convert to timestamp?

How get TIMEDIFF of each row's date field with the closest previous date row without a subquery?

How do I query for fields containing a given text in MySQL?

autosuggest showing blank li's

How to create a “Next Page” link to the “non-displayed” results of mySQL search?

How to pull grandchildren from database

How to connect to MySQL using ssh tunnel with perl

Idea how to implement server-push content without php looping

How to UPDATE a query with different arguments in MySQL

How to get an array of values from a mysql column based on an array

how to return selected data from mysql database in php

how to import excel file (XLSX) to mysql using nodejs

How to search for multiple values in a single field of mysql table using codeigniter active record?

How to delete multiple rows from MYSQL table using PHP

MySQL how to specify string position with LOAD DATA INFILE

How to use OdbcParameter for MySQL?

How to set daylight saving time in MySQL?

How to insert multiple rows from a textarea in MySQL

I don't understand this piece of MySQL notation and subsequently don't know how to do it in Postgresql

How to communicate with MySQL from java [duplicate]

How to on Performance_schema in mysql?