MySQL Forums
Forum List  »  PHP

Re: trouble figuring out joins, any gurus out there?
Posted by: Mike M
Date: October 04, 2009 08:33PM

Thanks for the reply, I put this on the back burner for a little while but i'm back.

I think i was explaining unclear what I'm trying to do, I think I need to do this in 2 steps. First one is easy, find all the todo_ids that are in the project:

SELECT d.todo_id
FROM project_tag pt
JOIN project p ON p.project_id = pt.project_id
JOIN tag t ON pt.tag_id = t.tag_id
JOIN todo_tag dt ON dt.tag_id = pt.tag_id
JOIN todo d ON d.todo_id = dt.todo_id
WHERE pt.project_id = '1'

The second step is for each of these todos if there are more tags associated with the todos than what is contained in the project. I wojuld just call this on each todo_id

SELECT tag.value FROM tag, todo_tag WHERE tag.tag_id = todo_tag.tag_id AND todo_tag.todo_id = '".$todo_id."'

but I am trying to combine these queries into just 1 query. Can I join the result I just created with the todo_tag table to find all the associated tag_ids?

Options: ReplyQuote


Subject
Written By
Posted
Re: trouble figuring out joins, any gurus out there?
October 04, 2009 08:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.