How to update column text value with concatenation of multiple columns text values?
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
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.
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>');
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]