1

I have a table which has a column id and a column isadmin.

I want to execute this query, which works just fine:

SELECT id FROM mytable WHERE isadmin = TRUE;

But instead of getting multiple rows I would like to get one row in csv format. I found this link and created the following query, which does not work, I get a MySQL error:

SELECT GROUP_CONCAT(id SEPERATOR ',') FROM mytable WHERE isadmin = TRUE;

The error message is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SEPERATOR ', ') FROM mytable WHERE isadmin = TRUE' at line 1

If this is not enough information just tell me and I will provide them.

Dharman
  • 26,923
  • 21
  • 73
  • 125
JRsz
  • 2,811
  • 4
  • 25
  • 43

1 Answers1

2

The comma is the defaul separator so you don't need

 SELECT GROUP_CONCAT(id ) FROM mytable WHERE isadmin = TRUE;

anyway is separator and nt seperator

SELECT GROUP_CONCAT(id SEPARATOR ',') FROM mytable WHERE isadmin = TRUE;
ScaisEdge
  • 129,293
  • 10
  • 87
  • 97
  • I read that about 50 times, still did not get it. This works well, thank you a lot :) – JRsz Jun 18 '16 at 20:26