October 22nd, 2012, 03:53 PM
How do I join these tables so I don't get 100+ junk results?
I'm working on problem #6 on this page pgrocer.net/Cis50/assign/quiztwo_F09.html
and frankly I don't know where to begin. Queries I've tried have returned 168 results when I should be getting less than 10. I know I have to join the tables in some way but haven't figured out which ones to join and how to join them. Any and all help is appreciated.
October 26th, 2012, 01:44 PM
1) Join orderz with ordline to get orders + line items
Originally Posted by AndroidZ
2) Join orderz with invcust to get customer name
3) Join ordline with inven to get item name
November 1st, 2012, 03:47 PM
I'm still confused. Trying to work out how to join orderz to both orderline and invcust. Do I use natural join?
Originally Posted by LKBrwn_DBA
November 1st, 2012, 04:28 PM
This is a simple example that lists orders by customer name, order date:
select ord.custid, cus.custname, ord.ordno, ord.ordate, orl.numord, orl.itemno, inv.itemname
from orderz ord join ordline orl on ord.ordno = orl.ordno
join inven inv on orl.itemno = inv.itemno
join invcust cus on ord.custid = cus.custid
order by cus.custname, ord.ordate