table E : id, title, datetime table L : id, place, xpos, ypos table M : id, title, datetime, contact, agenda table ER : parentid, childid, parenttype, child type data in ER : e.id, l.id, e, l -> E object linked to L object m.id, l.id, m, l -> M object linked to L object
I want to select all objects from table E and M such that they have a connection to object in L (in table ER) and that object has value of xpos>25 (arbitrary)
select * from L where xpos > 5 left outer join ER on ER.childid=L.id left outer join E on E.id=ER.parentid left outer join M on M.id=ER.parentid
I feel I'm missing the basic working of joins and am constructing a wrong query (approach here). Can it be combined in one query? Or do I have to use multiple queries, one for E and one for M to get the results from each of them?