SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast nerf's Avatar
    Join Date
    May 2004
    Location
    Sunshine Coast, Australia
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    access DB triple join query...

    Hi, yep im stuck, I made this query here
    select * from PRODUCTS inner join link on link.prodID = PRODUCTS.productID where link.sysID=1
    that joins 2 tables, i need to acquire more information off that query.
    I have a category table, where the fields are ID & name and the PRODUCTS table has a field called CategoryID so basically (and im not sure how to) i want to modify my exisiting query so i can set a categoryID aswell as link.sysID=1

    So basically i can then show each product under a header for its category where sysID=1

    In short the result would be like:

    System ID 1 has 2 Categories
    CATEGORY 1
    product 1
    product 2
    CATEGORY 2
    product 3
    product 4

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select columns
         , category.ID   as category_ID
         , category.name as category_name
      from PRODUCTS 
    inner 
      join link 
        on PRODUCTS.productID 
         = link.prodID 
       and link.sysID
         = 1
    inner
      join category
        on PRODUCT.CategoryID
         = category.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
  •