mysql

Add two string columns in mysql

Add two string columns –

Two predefined functions in MySQL for concatenate multiple columns –

  1. CONCAT
  2. CONCAT_WS
Student Table –
Student Table Example

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

Leave a Reply

Your email address will not be published. Required fields are marked *

× How can I help you?