Home > Archive > SQL Server Programming > June 2005 > Query Problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Werner 2005-06-11, 3:59 pm |
| Hi,
I have a table like this:
StringID,LanguageID and StringValue.
The table contains strings in different languages. Strings with the equal
meaning have the same StringID but a different LanguageID.
Here is a example:
LanguageID
1 - english
2 - german
StringTbl
1,1,home
1,2,Haus
2,1,tree
2,2,Baum
3,1,car
Now the problem: For some strings exists no translation, there is only an
english version available. How can I select a german sting and recive the
english version if no german version exist.
e.g. select StringValue from StringTbl where StringID = 1 and LanguageID = 2
???? or if LanguageID = 2 not exist then LanguageID =1.
Is it possible to use one select to achieve this?
Thanks for any help.
Werner
| |
| John Bell 2005-06-11, 3:59 pm |
| Hi
Try something like:
SELECT ISNULL(g.[string], e.[string]) as [string]
FROM stringtbl e
LEFT JOIN stringtbl g on e.stringid = g.stringid
WHERE g.langid = 2
and e.landid = 1
John
"Werner" wrote:
> Hi,
>
> I have a table like this:
> StringID,LanguageID and StringValue.
>
> The table contains strings in different languages. Strings with the equal
> meaning have the same StringID but a different LanguageID.
> Here is a example:
> LanguageID
> 1 - english
> 2 - german
>
> StringTbl
> 1,1,home
> 1,2,Haus
> 2,1,tree
> 2,2,Baum
> 3,1,car
>
> Now the problem: For some strings exists no translation, there is only an
> english version available. How can I select a german sting and recive the
> english version if no german version exist.
> e.g. select StringValue from StringTbl where StringID = 1 and LanguageID = 2
> ???? or if LanguageID = 2 not exist then LanguageID =1.
>
> Is it possible to use one select to achieve this?
>
> Thanks for any help.
> Werner
>
>
>
|
|
|
|
|