Need to return fewer rows than UNION (JOINs the answer?)
Posted in 2000
I'm trying to create a view with descriptions for ID's taken from another table. e.g. -- Products Table with multiple PART ID's where PART_DESC is stored in Parts Table Products Table: PROD_ ID PART1_ID PART2_ID PART3_ID 1 34 45 56 Parts Table PART_ID PART_DESC 34 Widget 45 Digit 56 Gidget I can use a union to return 3 rows: PROD_ID PART_DESC 1 Widget 1 Digit 1 Gidget How can I join PRODUCTS and PARTS tables to return a single row per product? PROD_ID PART1_DESC PART2_DESC PART3_DESC 1 Widget Digit Gidget I've tried some combinations of aliases and joins with no success yet Of course there might be NULLs in any of the Part IDs above PART1_ID The query should be ANSI-SQL compliant, if possible, for future portability. I hope it's not a problem with database design, though I'd appreciate it being pointed out if that's the case, since it's not too late to change it. Thanks for the help.