Reputation: 2941
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.
Upvotes: 1
Views: 125
Reputation: 133360
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;
Upvotes: 2