Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by sonicbhoc for Join to two tables

You are going to want to select from a JOIN statement. In this case, an INNER JOIN.

Try something like this:

 SELECT i.itemName, i.pricePerUnit, c.itemQuantity  FROM Items AS i  INNER JOIN ContainsItems ON i.itemID = c.itemID  WHERE i.invoiceID = @yourInvoiceID

Having aliases for tables in joins helps prevent collisions.


Viewing all articles
Browse latest Browse all 3

Trending Articles