Add two string columns in mysql
Add two string columns –
Two predefined functions in MySQL for concatenate multiple columns –
- CONCAT
- CONCAT_WS
Student Table –
1- CONCAT Example –
CONCAT( column1, column2, … )
MySQL Query –
SELECT CONCAT( first_name, " ", last_name ) AS fullname FROM student;
// Output => Ashok Singh
2- CONCAT_WS Example –
CONCAT_WS( ” “, column1, column2, column3, … )
MySQL Query –
SELECT CONCAT_WS( " ", first_name, middle_name, last_name ) AS fullname FROM student;
// Output => Ashok Kumar Singh
Add two string columns in mysql