CONCAT
joining strings together.
Overview
MySQL CONCAT joins text arguments in order and is useful for display names, codes, or export columns. In MySQL, any NULL argument makes the CONCAT result NULL, so use COALESCE first when the remaining pieces should be kept. Concatenation is convenient for presentation but should not replace sound data modeling or be applied carelessly in indexed filters.
Basic syntax
SELECT CONCAT(first_name, last_name) AS full_name FROM users;
Examples
CONCAT example
Join first_name and last_name from users into full_name and observe how argument order shapes the result.
Sample table
users| first_name | last_name |
|---|---|
| Tom | Lee |
| Jack | Chen |
| Lucy | Wang |
Run result
| full_name |
|---|
| TomLee |
| JackChen |
| LucyWang |
Common issues
Check each function; with CONCAT, use COALESCE first when a fallback value is required.
Common MySQL syntax starts at 1; verify argument rules when moving to another database.
The default removes leading and trailing spaces only, not spaces within the value.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.