
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to display columns name first name, last name as full name in a single column?
For this, use CONCAT() method in MySQL. Let us first create a table −
mysql> create table DemoTable ( FirstName varchar(50), LastName varchar(50) ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris','Brown'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('David','Miller'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('John','Doe'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('Adam','Smith'); Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+----------+ | FirstName | LastName | +-----------+----------+ | Chris | Brown | | David | Miller | | John | Doe | | Adam | Smith | +-----------+----------+ 4 rows in set (0.00 sec)
Following is the query to concatenate first name and last name to full name −
mysql> select concat(FirstName,' ',LastName) AS FullName from DemoTable;
This will produce the following output −
+--------------+ | FullName | +--------------+ | Chris Brown | | David Miller | | John Doe | | Adam Smith | +--------------+ 4 rows in set (0.00 sec)
- Related Articles
- Constructing full name from first name, last name and optional middle name in JavaScript
- How to separate last name and first names in single column into two new columns in MySQL?
- Display distinct column name in MySQL
- Split First name and Last name using JavaScript?
- MySQL GROUP BY and CONCAT() to display distinct first and last name
- How to display MySQL Table Name with columns?
- Java program to print the initials of a name with last name in full
- Python program to print the initials of a name with last name in full?
- MySQL query to conduct a basic search for a specific last name in a column
- How to create separate columns for first and last name in R?
- MySQL query to select everything to left of last space in a column with name records
- Add a column count in a MySQL query on the basis of last name records?
- Display records where first and last name begins with the same letter in MySQL
- Validate the first name and last name with Java Regular Expressions
- Select the table name as a column in a UNION select query with MySQL?

Advertisements