Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Populate Menu if submenu Items exist

Author  Topic 

bielen
Yak Posting Veteran

97 Posts

Posted - 2007-01-03 : 11:26:00
I have the following query:

select TASK_NAME,TASK_NUMBER, LEVEL, PROJECT_NUMBER FROM PROJECT_DATA
where PROJECT_NUMBER = 123 and LEVEL = 2

The values currently returned are:

PROJECT_NUMBER" "TASK_NUMBER" "TASK_NAME" "LEVEL"
123 1.9 Task 9 2
123 1.8 Task 8 2
123 1.7 Task 7 2
123 1.6 Task 6 2
123 1.5 Task 5 2
123 1.4 Task 4 2
123 1.3 Task 3 2
123 1.2 Task 2 2
123 1.1 Task 1 2

I also have the following values where the LEVEL = 3 in the PROJECT_DATA table:

PROJECT_NUMBER" "TASK_NUMBER" "TASK_NAME" "LEVEL"
123 1.8.xyz xyz 3
123 1.5.xyz xyz 3
123 1.4.stp stp 3
123 1.3.trv trv 3
123 1.2.apl apl 3

How can I have menu where the level = 2 only display the five entries where there is a correponding subset records where for example, the TASK_NUMBER is like '1.3%' AND LEVEL = 3 for the five matching records.

Thanks for any info.

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-03 : 15:42:06
SELECT PD.TASK_NAME, PD.TASK_NUMBER, PD.LEVEL, PD.PROJECT_NUMBER
FROM PROJECT_DATA PD
WHERE PD.PROJECT_NUMBER = 123 and PD.LEVEL = 2
AND EXISTS (SELECT * FROM PROJECT_DATA PD1
WHERE PD1.PROJECT_NUMBER = PD.PROJECT_NUMBER AND PD1.LEVEL = 3)
Go to Top of Page
   

- Advertisement -