SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display records with sub-records

    What would be the best way to print out records with sub-records attached to them? Suppose I have 2 tables, something like this:

    User table:

    User_id User_name
    1 John
    2 Mick

    Movie table:

    User_id Movie_name Rating
    1 Die Hard 5
    1 MIB 8
    2 Iron Man 6


    What I want to get, is this:

    John:
    • Die Hard (5)
    • MIB (8)


    Mick:
    • Iron man (6)


    Should I do an inner join and process the query result using, for example, PHP or is there a better way to organize the result with the help of mysql?

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would do the formatting in PHP as you suggest.


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
  •