SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Combining two SELECT results

    Hi guys!

    Sorry if this has been asked before, but I don't even know how to express the question succinctly enough to even search for what I'm struggling with.

    I have one table containing bookmark data, while the other table contains tag data.

    I need to grab the bookmark (singular), while at the same time grabbing all of the tags (plural) for that bookmark, and have them returned as one combined record.

    Each row in the tag table contains the ID of the bookmark to which it relates.

    I'm guessing this is entirely achievable, yes?

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. If you have 1 bookmark containing more tags, you can get the data exactly that way. It's up to your language that you use how it formats the result.

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you an attempt to show us, which can help us to understand what you need or are trying?

    bazz

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Forbes View Post
    I'm guessing this is entirely achievable, yes?
    you betcha

    use a join query, with a GROUP BY clause on the bookmark id, and a GROUP_CONCAT function in the SELECT clause to concatenate all the tags for that bookmark into a single value
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    you betcha

    use a join query, with a GROUP BY clause on the bookmark id, and a GROUP_CONCAT function in the SELECT clause to concatenate all the tags for that bookmark into a single value
    Excellent, that worked a treat!

    However, I've inadvertently created another problem elsewhere, which killed MySQL!

    I think I'll need to post that as a separate question in a thread of its own.

    Thanks!


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
  •