Reputation:
I have columns in one! table; example (Hallo(Deutsch)=Hello, Montag(Deutsch)=Monday)
Id, LanguageID, ResourceName, ResourceValue
1 1 Hello Hello
2 2 Hello Hallo
3 1 Monday Monday
4 2 Monday Montag
How can I see to results of a query like this:
ResourceName ResourceValue(languageID=1) ResourceValue(LanguageID=2)
Hello Hello Hallo
Monday Monday Montag
Upvotes: 0
Views: 93
Reputation: 247850
You can get the result using an aggregate function with a CASE
expression:
select ResourceName,
max(case when languageid = 1 then ResourceValue end) Language1,
max(case when languageid = 2 then ResourceValue end) Language2
from yourtable
group by resourcename
See SQL Fiddle with Demo.
If you have additional LanguageId
values, then you can add more case expressions.
Upvotes: 4
Reputation: 31710
This might work...
select
t1.resourcename,
t1.resourcevalue,
t2.resourcevalue
from
tablename t1,
tablename t2
where
t1.resourcename = t2.resourcename and
t1.languageid = 1 and
t2.languageid = 2
Upvotes: 2