Monday, March 19, 2012

Nested SELECT HELP....

Hi all,
I have the following databasedesign :

www.marinescu.dk/databasedesign.pdf

which i have a nested SELECT on but i need some more information which i
don't know how to retrieve. I have the following SELECT :

SELECT DISTINCT Resource.ResourceID, Localized.ResourceValue,
Localized.Font, Resource.ResourceName, Resource.Comment, Type.TypeName FROM
Localized, Resource,Type WHERE Localized.ResourceID = Resource.ResourceID
AND Resource.TypeID = Type.TypeID ORDER BY Resource.ResourceID

For some Resources there are Rules. I will like to have a new column named
RulesText in my query where there will be shown the RuleText if there is any
for that particular Resource.

Could anybody help me here ??

Best Regards
Mihai MarinescuSELECT DISTINCT
R.ResourceID, L.ResourceValue, L.Font, R.ResourceName, R.Comment,
T.TypeName, RL.RuleText
FROM Localized AS L
JOIN Resource AS R ON L.ResourceID = R.ResourceID
JOIN Type AS T ON R.TypeID = T.TypeID
LEFT JOIN ResourceRule AS RR ON RR.resourceid = R.resourceid
LEFT JOIN Rules AS RL ON RL.ruleid = RR.ruleid
ORDER BY R.ResourceID

(untested)

--
David Portas
----
Please reply only to the newsgroup
--

No comments:

Post a Comment