title: MySQL - SELECT, JOIN
body: <p>Few months ago I was programming a simple application with som other guy in PHP. There we needed to preform a SELECT from multiple tables based on a userid and another value that you needed to get from the row that was selected by userid.</p>
  <p>My first idea was to create multiple SELECTs and parse all the output in the PHP script (with all that mysql_num_rows() and similar functions for checking), but then the guy told me he'll do that. &quot;Okay no problem!&quot; I thought, just much more less for me to write. Well, what a surprise when i found out he did it with just one SQL statement:</p>
  <pre><code>SELECT
    d.uid AS uid, p.pasmo_cas AS pasmo, d.pasmo AS id_pasmo ...
  FROM
    table_values AS d, sectors AS p
  WHERE
    d.userid='$userid' and p.pasmo_id=d.pasmo
  ORDER BY
    datum DESC, p.pasmo_id DESC
  </code></pre>
  <p>(shortened piece of the statement (...))</p>
  <h3>Mostly I need to know the differences between this method (is it the right way to do this?) and JOIN - when should I use which one?</h3>
  <p>Also any references to explanations and examples of these two would come in pretty handy (not from the MySQL ref though - I'm really a novice in this kind of stuff and it's written pretty roughly there.)</p>