I’m having a small trouble since it was a long time ago i studies databases and querys.
For example i’ll have two tables for cd:s, one with data and one with alternative translations.
In the CD-table i have the original language, and it looks something like this
Table for CDs (cds):
id | name | language
-----------------------
1 | aaa | en
2 | bbb | en
3 | ccc | fi
Table for languages (languages):
cd_id | language | name
-----------------------
1 | fi | AAA
1 | de | AAACHTUNG
3 | en | CCC
Now, i want to get all these cd:s in for example german, if there’s no translation made i want it to be in the original language…
Edit:
German = de
Since there’s only one german translation (on CD #1) i want cd 2 & 3 in thier original names.. English and finnish in this case…
How can i do this?
Edit 2:
In this case when i ask for ‘de’ i would get:
AAACHTUNG
bbb
ccc
If i ask for ‘en’ i would get
aaa
bbb
CCC
And so on…
This should do the trick (SQL Fiddle):