Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query Help...

Posted on 2011-03-16
3
Medium Priority
?
269 Views
Last Modified: 2012-05-11
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
Comment
Question by:kevp75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1800 total points
ID: 35151807
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
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 200 total points
ID: 35151890
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
 
LVL 25

Author Closing Comment

by:kevp75
ID: 35151971
sweet.  thanks guys
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question