title: MySQL 3 tables in one query?
body: <p>I'm trying to create a efficient query which will retrieve 'projects' from a database and all the relevant 'tags' which have been assigned to that particular project.</p>
  
  <p>My table setup mimics that of wordpress, and is a tad complicated:</p>
  
  <pre><code>term
  - Where I define the tags name, slug etc
  
  term_relationships
  - Links the project to a term in the above table.
  
  term_taxonomy
  - Defines the taxonomy of each of terms in the term table e.g. 'category', 'tag'.
  </code></pre>
  
  <p>So, what I need to do is first query the term_taxonomy table for any entries with the taxonomy 'tag', then filter these results so that only the terms specified in term_relationships are returned. Finally I then need to query the term table to return the relevant tags.</p>
  
  <p>My question is which is fastest way of doing this? I imagine it would be best to split it into multiple queries eg. Query 1: retrieve project, Query 2: retrieve project tags but please consider I may have up to 20-30 projects per page.</p>
  
  <p>PS: I know it'd be far easier to just create a new table specifically for tagging, but I'd like to confine it to my current setup for now.</p>
  
  <p>Any help would be much appreciated, as this is driving me mad!</p>