Combining two fields data into one field in the same database table

If you only want to display the name after combining the fields then simply use:
SELECT CONCAT(first_name, ‘ ‘, last_name) AS full_name FROM table_name;

But if you want to save them in a separate db field then use UPDATE query. To update all the records in the table in one shot use:

UPDATE table_name SET full_name = CONCAT(first_name, ‘ ‘, last_name);

Advertisements

2 thoughts on “Combining two fields data into one field in the same database table

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s