I am trying to make a multi-table query that I am not quite sure how to do properly. I have User, Message, Thread, and Project.
A User is associated with Message/Thread/Project as either the Creator or as it being 'shared' with them.
A Message is contained within a Thread (associated by message.thread_id and thread.id), and a Thread is contained within a Project (associated by thread.project_id and project_id).
I would like to create a query where given a User.id value, it will return all messages that the user has access to, as well as the Thread and Project name that that message is under, both as Creator or 'Shared'. I use a table to handle the 'shares'. The rough diagram is: http://min.us/mvpqbAU
There are more columns in each, but I left them out for simplicity.
Best Answer
looks like you need to use "join" syntax. Something like:
Of course, this will have to be modified to include the fields you actually want returned and whatever sorting and ordering you may want... but this should get you started. Good luck!