I have two tables I need to join. The left table does not have a relation to the right table, but the right table DOES have a relation back to the left table. For the life of me I cannot figure out the syntax, I keep getting an error "Path expected for join!". I don't know what that means.
For the moment, here's what I'm trying to do:
SELECT host.address,session.openedAt,session.closedAt FROM Hosts as host LEFT OUTER JOIN Sessions as session WHERE (session.relHost.id = host.id AND session.closedAt is null)
This doesn't work at all, I keep getting the query error: "Path Expected For Join!". But then, I'm not even sure this will get me my intended results. The session table may have multiple (open and closed) sessions, each pointing to the same relHost. What I want is a table that has every line of the host table (with no duplicates), along with a boolean column indicating whether there is at least one open session for that host. (session.opened != null and session.closed == null)
I'm really at a loss how to do this. (My MySQL knowledge is limited, my HQL even moreso). I've tried every bit of syntax I could find on the internet, and I can't even get the most basic of joins to work, so I'm apparently missing some concept here. (It doesn't help that none of the examples I found had before and after tables to show what the syntax actually does)
Any help would be greatly appreciated.
Charles.
|