• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

SQL Query Help...

Havin a brain fart here...  I need to get the c.catID in this query, how can I do that?


Select d.catID, d.catName, 

1

From vwSelectPartCategory d
Where d.catID In (Select a.parentID From vwSelectPartCategory a 
Where a.catID In(Select b.parentID From vwSelectPartCategory b 
Where b.catID In (Select c.catID From vwSelectPart c 
Where c.partMake Like '%VW%' And 
c.partModel Like '%Jetta%')));

Open in new window

0
kevp75
Asked:
kevp75
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
hmmm

Select d.catID, d.catName, 1, c.CatID
From vwSelectPartCategory d
JOIN vwSelectPartCategory a
  ON a.ParentID = d.CatID
JOIN vwSelectPartCategory b
  ON b.ParentID = a.catID
JOIN vwSelectPart c
  ON c.catID = b.CatID
 AND c.partMake Like '%VW%' 
 And c.partModel Like '%Jetta%'

Open in new window

0
 
SharathData EngineerCommented:
use DISTINCT key word, if you have multiple records returned because of JOIN conditions.
SELECT DISTINCT d.catID, 
                d.catName, 
                1, 
                c.CatID 
  FROM vwSelectPartCategory d 
       JOIN vwSelectPartCategory a 
         ON a.ParentID = d.CatID 
       JOIN vwSelectPartCategory b 
         ON b.ParentID = a.catID 
       JOIN vwSelectPart c 
         ON c.catID = b.CatID 
            AND c.partMake LIKE '%VW%' 
            AND c.partModel LIKE '%Jetta%'

Open in new window

0
 
kevp75Author Commented:
sweet.  thanks guys
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now