SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    concat & group_concat

    Hi Guys

    I'm trying to group multiple rows into one column on my database. I'm using the following sub query:

    PHP Code:
    concat(group_concat(display_town', 'display_county'<br>')) as display_name 
    The output i'm getting is:

    Code:
    Canterbury, Kent
    ,Kent, Kent
    However the output i'm looking for is:

    Code:
    Canterbury, Kent
    Kent, Kent
    How can I get rid of that extra comma?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,260
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Code:
    GROUP_CONCAT(CONCAT(display_town, ', ', display_county) SEPARATOR '<br>'))
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    Code:
    GROUP_CONCAT(CONCAT(display_town, ', ', display_county) SEPARATOR '<br>'))
    You're a star thank you


Bookmarks

Posting Permissions

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