SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Resultset acrosse several tables with null values?

    I'm looking for some help/pointers on how to create a result set based on the following tables.

    tbl_part_categories (contains categories)
    part_category_id - unique
    part_category_name

    tbl_parts (contains part details)
    part_id - unique
    part_name
    part_category_id

    tbl_required_parts (contains a list of parts required for a given assembly type)
    assembly_type - contains duplicates for each part category required
    part_category_id

    tbl_assemblies (contains details for given assembly)
    assembly_id - unique
    assembly_name

    tbl_assemblies (links parts to assemblies)
    assembly_link_id - contains duplicates for every part linked to id
    part_id



    What I'm needing is code to produce a result showing all the parts fitted to any given assembly, sorted by category, but also including null values for any required components that are missing.
    For example-

    Code:
    part_category_name | part_name
         Category 1    |   Part 1
         Category 1    |   Part 2
         Category 2    |   NULL
         Category 3    |   Part 6

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,408
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    You'll have to JOIN the tables (INNER JOIN, OUTER JOIN) depending on what you need.


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
  •