T-SQL Where statement - OR
Posted
by Zyphrax
on Stack Overflow
See other posts from Stack Overflow
or by Zyphrax
Published on 2010-04-20T11:43:29Z
Indexed on
2010/04/20
11:53 UTC
Read the original article
Hit count: 381
Sorry for the vague title but I really didn't know what title to give to this problem:
I have the following result set:
ID Data Culture
1 A nl-NL
2 B nl-NL
3 C nl-NL
4 A en-GB
5 B en-GB
6 A en
7 B en
8 C en
9 D en
10 A nl
I would like to mimic the ASP.Net way of resource selection, user Culture (nl-NL)
SELECT Data FROM Tbl WHERE Culture = 'nl-NL'
Or when there are no results for the specific culture, try the parent Culture (nl)
SELECT Data FROM Tbl WHERE Culture = 'nl'
Or when there are no results for the parent culture, try the default Culture (en)
SELECT Data FROM Tbl WHERE Culture = 'en'
How can I combine these SELECT-statements in one T-SQL statement?
I'm using LINQ so a LINQ expression would be even greater.
The OR-statement won't work, because I don't want a mix of cultures.
The ORDER BY-statement won't help, because it returns multiple records per culture.
© Stack Overflow or respective owner