SQL CONCAT() Function - The Coding Shala
Home >> Learn SQL >> SQL CONCAT() function
NOTE: In MySQL, we use '||' instead of CONCAT().
The following 'emp' table is used for the example -
SQL CONCAT() Function
The SQL CONCAT() is used to concatenate two strings. In MySQL, we use '||'.
SQL CONCAT() Syntax
The basic syntax of SQL CONCAT() is as follows -
SELECT CONCAT(column_name1, column_name2, ..) FROM table_name
NOTE: In MySQL, we use '||' instead of CONCAT().
The following 'emp' table is used for the example -
emp_id emp_name city dept_no salary 1 Akshay Pune 101 50000 3 Nikhil Pune 101 51000 5 Mohit Delhi 103 40000 6 Shubham Surat 105 42000 7 Akash Mumbai 106 45000
SQL CONCAT() Example
The following SQL query will concatenate two columns using || in MySQL -
SQL >> select emp_name || ' is from ' || city as 'Emp Detail' from emp; Output >> Emp Detail Akshay is from Pune Nikhil is from Pune Mohit is from Delhi Shubham is from Surat Akash is from Mumbai
Other Posts You May Like
Comments
Post a Comment