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
 Transact-SQL (2000)
 Selecting multiple values from 1 field in 1 record

Author  Topic 

sahu74
Posting Yak Master

100 Posts

Posted - 2004-07-06 : 11:38:23
I have 3 tables with the following field structure:

Survey_folder(T3): FolderID, DescLevel_0, PrefixSubfolder
Survey_Subfolder(T1): SubfolderID, DescLevel_1
Survey_WebName(T2): Abbr, WebName

I am having this query:



SELECT T1.Level1ID, T1.DescLevel_1, T2.WebName, T3.PrefixSubFolder, T2.WebName
FROM Survey_SubFolder T1, Survey_WebName T2, Survey_Folder T3
WHERE ((T1.DescLevel_1 = T2.Abbr) OR (T3.PrefixSubFolder = T2.Abbr))
AND T1.FolderID = T3.FolderID
AND T1.FolderID =1

...for which I get the following results:
1 General CES Survey 2002 CES 02 CES Survey 2002
1 General General CES 02 General
2 Tables CES Survey 2002 CES 02 CES Survey 2002
2 Tables Tables CES 02 Tables

The results I desire to have is:
1 General General CES 02 CES Survey 2002
2 Tables Tables CES 02 CES Survey 2002


...but I cannot think of a way to get that query.

Any help will be appreciated.

Thank you.
PKS

sahu74
Posting Yak Master

100 Posts

Posted - 2004-07-06 : 12:39:18
I think I found the solution.


SELECT T1.Level1ID, T1.DescLevel_1, T2.WebName, T3.PrefixSubFolder, T4.WebName
FROM Survey_SubFolder T1, Survey_WebName T2, Survey_Folder T3, Survey_WebName T4
WHERE T1.DescLevel1 = T2.Abbr
AND T3.PrefixSubFolder = T4.Abbr
AND T1.FolderID = T3.FolderID
AND T1.FolderID =1


Any suggestions to do this in another way is welcome.

Thank you.
PKS.
Go to Top of Page
   

- Advertisement -