MySQL, select from different table... IF

Posted by gubbfett on Stack Overflow See other posts from Stack Overflow or by gubbfett
Published on 2012-11-09T16:57:26Z Indexed on 2012/11/09 16:59 UTC
Read the original article Hit count: 130

Filed under:
|
|

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...

How can i do this?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql