query data from a parent-child table

G

grupy

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?
 
P

PieterLinden via AccessMonster.com

grupy said:
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";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top