I have a database sort of like a dictionary. Essentially, there are six tables:
words_a (id_a, word_a) contains all words of language A
words_b (id_b, word_b) contains all words of language B
words (id, id_a, id_b) connects words of language A and their corresponding translation to language B
categories (id, cat_id) assigns categories to every worda-wordb-relationship from words-table
Now what I want to do is get all translations in a certain category.
I choose a category id (cat_id) and get all the word-word-relationships (id) in that category, then I get the two corresponding word IDs (id_a and id_b) for those relationships:
SELECT id_a, id_b
FROM words, (
SELECT *
FROM `categories`
WHERE cat_id =6
) AS temp
WHERE words.id = temp.id
This gives me a table with the IDs of all words in language A and the IDs of their corresponding translations to language B in category 6. Now I need the actual words to the IDs.
SELECT word_a, word_b FROM words_a,words_b, (
SELECT id_a,id_b
FROM words, (
SELECT *
FROM categories
WHERE cat_id=6 ) AS t
WHERE words.id = t.id ) AS temp
WHERE ??? )
What should my where-clause look like?