1

Supposed that I have a table like this:

**tbl_purchase**
PurchaseID
Date
Supplier

**tbl_purchaseitem**
PurchaseItemID
PurchaseID

I want to create a query where it will return something like:

**Header**
PurchaseID = 2
Date: 4/26/12
Supplier:stackoverflow

*Items*
PurchaseItemID:3
PurchaseID:2

PurchaseItemID:4
PurchaseID:2

PurchaseItemID:5
PurchaseID:2

Sir/Ma'am your answers would be of great help and be very much appreciated.

2 Answers 2

1
Select * from tbl_purchase 
inner join 
tbl_purchaseitem
on 
tbl_purchase.PurchaseID = tbl_purchaseitem.PurchaseID
where 
PurchaseID = 2 
and 
Date = '4/26/12' 
and 
Supplier = 'stackoverflow'
Sign up to request clarification or add additional context in comments.

Comments

1

Like this:

SELECT pi.*
FROM tbl_purchase p
INNER JOIN tbl_purchaseitem pi
     ON p.PurchaseID = pi.PurchaseID
WHERE p.PurchaseID = 2 AND
      p.Date       = '2012-04-26' AND
      p.Supplier   = 'stackoverflow'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.