SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 7 votes, 2.71 average. Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old February 25th, 2005, 10:13 AM
imtiny imtiny is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 imtiny New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
sql help -how to join 3 tables?

helooo...

i have 3 tables -Recipes, Ingredients and Products.

Recipes table:
RecipeID -PK

Ingredients table:
IngredientID -PK
IngreRecipeID -Foreign key to Recipes table
IngreProductID -Foreign key to Products table

Table:
ProductID -PK

how do i join them into 1 recordset?

Reply With Quote
  #2  
Old February 25th, 2005, 03:29 PM
kurt kurt is offline
Contributing User
Tutorialized Novice (500 - 999 posts)
 
Join Date: Jan 2004
Posts: 507 kurt New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 5 m 48 sec
Reputation Power: 0
Just specify the fields you want from each table and join the ids:

Code:
select
    r.recipe_name,
    i.ingredients_list,
    p.products_list
from
    recipes r,
    ingredients i,
    products p
where
    r.RecipeID = i.IngreRecipeID and
    i.IngreProductID = p.ProductID
;
Comments on this post
aitken325i agrees!

Reply With Quote
  #3  
Old August 21st, 2008, 06:58 PM
mdesoysa mdesoysa is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 1 mdesoysa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by kurt
Just specify the fields you want from each table and join the ids:

Code:
select
    r.recipe_name,
    i.ingredients_list,
    p.products_list
from
    recipes r,
    ingredients i,
    products p
where
    r.RecipeID = i.IngreRecipeID and
    i.IngreProductID = p.ProductID
;


Hey there,
what if you have seperate tables for the FK's? So then you would also have a ingredrecipe table and a ingredproduct table...

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > sql help -how to join 3 tables?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap