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.
WernerHi
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
>
>
Monday, March 26, 2012
Query Problem
Labels:
contains,
database,
equalmeaning,
languageid,
languages,
microsoft,
mysql,
oracle,
query,
server,
sql,
strings,
stringvalue,
table,
thisstringid
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment