Home > Enterprise >  How to get Rows values as comma or semi colon sepeared values as output in sql
How to get Rows values as comma or semi colon sepeared values as output in sql

Time:04-28

Table name employee
Emp_id      Emp_name     emp_language
1           john         Java
2           Ragul        Python
3           April        Java

I need a query to get output like

1,john,Java
2,Ragul,Python
3,April,Java

CodePudding user response:

You can use CONCAT_WS() function such as

SELECT CONCAT_WS(',',Emp_id,Emp_name,emp_language)
  FROM employee

which is similar to CONCAT() but no need to repeat the seperator by keeping as the first argument.

  • Related