title: MySQL unknown column in ON clause
body: <p>I have the following MySQL query:</p>
  
  <pre><code>SELECT p.*,
      IF(COUNT(ms.PropertyID) &gt; 0,1,0) AS Contacted,
      pm.MediaID,
      date_format(p.AvailableFrom, '%d %b %Y') AS 'AvailableFrom',
      astext(pg.Geometry) AS Geometry
  FROM property p, propertygeometry pg
      JOIN shortlist sl ON sl.PropertyID = p.id AND sl.MemberID = 384216
      LEFT JOIN message ms ON ms.PropertyID = p.id AND ms.SenderID = 384216
      LEFT JOIN property_media pm ON pm.PropertyID = p.id AND pm.IsPrimary = 1
  WHERE p.paused = 0
      AND p.PropertyGeometryID = pg.id
  GROUP BY p.id
  </code></pre>
  
  <p>And I'm getting this error:</p>
  
  <p><strong>#1054 - Unknown column 'p.id' in 'on clause'</strong></p>
  
  <p>As far as I can see the query looks right, any idea what could be wrong?</p>