[eluser]Assim[/eluser]
I want to write a query which is quite difficult.
I have 3 tables:
- tags (columns: TagID)
- tagpages (columns:
TagPageID, TagID, PageID)
- tagtext (columns:
TagTextID, TagID, LanguageCode, Text)
Columns in italics aren't to be used, they are just for the primary key.
To explain this, each tag will be associated with a TagID, each page will be associated to a TagID from tagpages table, and tagtext holds the tag translation for each language.
Now I want to write a SELECT statement to get all tags for a particular page but written in a specific language. The LanguageCode column is equal to $language
Here's what I thought of doing:
// Get all tag IDs of a page
SELECT TagID FROM tagpages WHERE PageID = '$page_id'
// This will bring the tag translation of a tag for a page
SELECT Text FROM tagtext WHERE LanguageCode = '$language' WHERE TagID = '$tag_id'
How do I get all the tags for a particular page and show the text from the selected language?
Or maybe we could use a foreach function after we execute the first query? Any ideas?