Hello,
Given the following tables:
I'm trying to write a SQL query that returns this result set:
I know how to join all three tables to return the first two columns, but I'm struggling to use the PARENT_OID value from the CAT table to retrieve the category name of that category's parent category and then return it in the same result set. Any ideas?
TIA,
Tom
Given the following tables:
Code:
SKU Table
OID NAME
=== ================
1 IBM ThinkPad T23
2 Dell GX150
3 Compaq Evo D510
CAT Table (PARENT_OID->CAT.OID)
OID NAME PARENT_OID
=== ========= ==========
1 Computers NULL
2 Notebooks 1
3 Desktops 1
MAP Table (OID->SKU.OID, PARENT_OID->CAT.OID)
OID PARENT_OID
=== ==========
1 2
2 3
3 3
I'm trying to write a SQL query that returns this result set:
Code:
PRODUCT NAME CATEGORY PARENT CATEGORY
================ ========= ===============
IBM ThinkPad T23 Notebooks Computers
Dell GX150 Desktops Computers
Compaq Evo D510 Desktops Computers
I know how to join all three tables to return the first two columns, but I'm struggling to use the PARENT_OID value from the CAT table to retrieve the category name of that category's parent category and then return it in the same result set. Any ideas?
TIA,
Tom