Joining Tables Based on Equality

An extract from the PARTS/ORDERS join provides a clue as to what is missing:

30-JUN-1996 TRUE WHEEL          42          54 PEDALS
30-JUN-1996 BIKE SPEC           54          54 PEDALS
30-MAY-1996 BIKE SPEC           10          54 PEDALS

Notice the PARTNUM fields that are common to both tables. What if you wrote the following?

						SELECT  O.ORDEREDON, O.NAME, O.PARTNUM,
						P.PARTNUM, P.DESCRIPTION
						FROM ORDERS O, PART P
						WHERE O.PARTNUM = P.PARTNUM ORDEREDON NAME PARTNUM PARTNUM DESCRIPTION =========== ========== =========== ========= ============== 1-JUN-1996 AAA BIKE 10 10 TANDEM 30-MAY-1996 BIKE SPEC 10 10 TANDEM 2-SEP-1996 TRUE WHEEL 10 10 TANDEM 1-JUN-1996 LE SHOPPE 10 10 TANDEM 30-MAY-1996 BIKE SPEC 23 23 MOUNTAIN BIKE 15-MAY-1996 TRUE WHEEL 23 23 MOUNTAIN BIKE 30-JUN-1996 ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.