I'm somewhat new to mysql/php and I'm not sure what the best way is to go about this problem.
I basically have a table of english words and another table of translations.
|ID | Word | | fkID | Language | Translation |
| 0 | Dog | | 0 | Spanish | perro |
| 1 | Cat | | 0 | French | chien |
| 1 | German | Katze |
| 1 | Spanish | gato |`
On my php site I want to list out each english word in a table with all translations next to it.
| Word | Spanish | French | German |
| Dog | perro | chien | |
| Cat | gato | | Katze |
I can brute force this by joining the two tables and then looping through the result in php to find all translations for a given word and then making an array for each word that is aligned to the languages, but it seems like a very very inefficient way to do this.
Is there a better way?
(Is it possible to have mysql return a result that looks just like my desired output where the column names are the languages. I know I could just have a column for each language, but that could end up being a hundred columns that aren't used.)