Badcoder
Badcoder

Reputation: 23

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

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

Upvotes: 0

Views: 72

Answers (1)

Barbaros Özhan
Barbaros Özhan

Reputation: 65228

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.

Upvotes: 1

Related Questions