CONCAT() in SQL

We use CONCAT() function in SQL to concatenate two or more column’s data.

To understand CONCAT(), we are going to create a database ‘jai_school‘.

CREATE DATABASE jai_school;

The database contains the table, so make a table: users

CREATE TABLE users(name varchar(50), village VARCHAR(50), district VARCHAR(50), state VARCHAR(50), country VARCHAR(50));

Insert some data

INSERT INTO users(name,village,district,state,country)VALUES("Ram","Sewad Chhoti","Sikar","Rajasthan","India");
INSERT INTO users(name,village,district,state,country)VALUES("Rahim","Sewad bari","sikar","Rajasthan","India");

Use CONCAT() function

SELECT CONCAT(name,', ',village,', ',district,', ',state,', ',country) AS Address FROM users;

Other Articles


SQL CASE
SQL MIN() and MAX() functions
SQL operators

Leave a Comment