title: PHP MYSQL Select query on two tables with common field
body: <p>I need to get record from two tables that have the same column (lease). I use the code below to get the records from the table (rows) where $q is equal to the (lease) column. This works fine however I would like to get records out of a different table (units) that also has a (lease) column in the same select query and use all these records in a while loop.  Below is the code i am currently using to pull the data out of one table, could someone please help me modify the code to pull data out of both tables. Is this possible? or am i going about this the wrong way? I have tried looking into JOIN but i just cant seem to get my head around it, have tried many examples but none seem to work.</p>
  
  <pre><code>    $sql = "SELECT * FROM rows WHERE lease = '".$q."'";
  $result = mysqli_query($conn, $sql);
  
  
  if (mysqli_num_rows($result) &gt; 0) {
      // output data of each row
      while($row = mysqli_fetch_assoc($result)) {
  echo "row " . $row["row_id"]. "Capacity" . $row["capacity"]. "&lt;br&gt;";*/
  
  
  }
  </code></pre>