Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011

    Unanswered: MySQL: Group Concat using Single Quotes as a Separator


    I'm trying to add a single quote around each username when it spits out the results. The closest thing I got was this:

    SELECT GROUP_CONCAT(username SEPARATOR "','" ) AS Usernames FROM auth;

    It worked and it added a single quote around each username EXCEPT for the first and last username on the list. Does anyone know how to fix this?

    Thank you for the help.


  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    1. i bet i know why you're doing this, and as the kids say these days, "ur doin it wrong"

    2. here's your extra quotes around them all --

    SELECT CONCAT("'",GROUP_CONCAT(username SEPARATOR "','"),"'") AS ... | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts