SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stacking/grouping same ID

    Hey,

    I have a column called message_id and I would like to stack all of the IDs that match each other under each other.

    Basically what I'm doing is as follow:

    1. The user inputs a message
    2. The message gets assigned an ID.
    3. If a another use replies to that same ID it gets put right under it. (like a forum in a way)

    I've been reading up on the GROUP clause but I'm not sure if thats what I'm looking for.

    Does anyone know on how to group them together? thanks

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2008
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select * from messages
    order by message_id

  3. #3
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me elaborate.

    If I have 5 rows with ID 125 then those rows need to stack.

    At the same time I might have another 10 rows with ID 86, those need to stack separately... etc.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    define "stack"

    sounds like you want ORDER BY message_id
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •