title: MySQL Query - Trouble with joins, filtering results
body: <p>I'm in way over my head with this query. Any help would be immensely appreciated. I'll try and break it down as simply as I can, but please let me know if I'm being too vague. </p>
  
  <p>There are four sections: criminal, family, civil, and business. Each has a judgeID and a userID of the user who last updated the report, along with report information.</p>
  
  <p>Then there is a users table, with userID and userType. </p>
  
  <p>There is a judges table with a judgeID and judge name. </p>
  
  <p>What I'm trying to do: Get all current reports from one of the four sections ($court) based on current month and year, find the name of each judge that corresponds with each judgeID on the reports found, and then (this is where I'm having trouble) filter the reports based on the userIDs that are of userType 'user' (rather than admin). </p>
  
  <p>Here's what I have (a little bit of PHP in there):</p>
  
  <pre><code>$query = "SELECT Name FROM judges LEFT JOIN $court
         ON ($court.JudgeID = judges.JudgeID)
         where Month='$month' and Year='$year' order by Name asc;";
  </code></pre>
  
  <p>It's just the subsequent filtering of userIDs by userType that I'm having trouble with.  </p>