I have a table called Languages which stores the languages every person stored in Persons table is able to talk, then I have a table called Homework which stores all the homework every person has to do, but related to a language. I'm able to select the homework person 1 has to do for language 1 (Left join), but also would like to be able to select in the same query the language person 1 is able to talk. Could someone give me a hint how to accomplish that? A left join to Languages will screw the results as will mess with languages on Homework table.
Languages and Persons are Many2One, the same goes for Homework and Persons.
That works but gets screw when I add a second left join:
SELECT p.id, l.id, h.id
FROM Persons AS p
LEFT JOIN Homework AS h ON h.person_id = p.id
#LEFT JOIN Languages AS l ON l.person_id = p.id #Screws the result multipliying by the number of available languages
WHERE p.id = 1
AND h.language_id = 1
I would like to combine the above query and the following:
SELECT *
FROM languages
WHERE person_id=1