A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

query data from a parent-child table



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2010, 10:47 PM posted to microsoft.public.access.queries
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default query data from a parent-child table

grupy wrote:
Id like to know how I can query lets say a specific record from a parent-chil
table

For example, lets say parent table is Products using ProductID as the primar
key and its child table is Customer using CustomerID as its key

Id like to query one product and all its specific customers into a table b
using a query. Can someone pls point me into the appropriate direction?


Consider an Invoice. Standard tables for it are something like
Customer(CustomerID (PK), CustomerName....)
Invoice(InvoiceNo (PK), InvoiceDate, InvCustomerID (FK)...)
LineItem(InvoiceNo (PK1), ProductID (PK2), Quantity....)

join all the tables on PK/FK.

Select Customer.CustomerName, Products.ProductName
FROM Customer INNER JOIN Invoice ON Customer.CustomerID = Invoice.
InvCustomerID
INNER JOIN LineItem ON Invoice.InvoiceNo = LineItem.InvoiceNo
WHERE Products.ProductName = "Some Product";

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201005/1

 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.