title: MySQL FROM multiple tables LEFT JOIN Unknown column in 'on clause'
body: <p>I've got an interesting query that I seem to be having trouble with.</p>
  
  <p>I need to select data from several tables and join on an additional table that has a column that may not be present on the other tables.</p>
  
  <p>I've tried a couple of angles on this.  Here's the first one:</p>
  
  <pre><code>SELECT SiteTree.*, Page.*, AlbumItem.*, Album.*
  FROM SiteTree, AlbumItem, Album
  LEFT JOIN Page ON SiteTree.ID = Page.ID
  </code></pre>
  
  <p>Throws this: #1054 - Unknown column 'SiteTree.ID' in 'on clause', presumebly because when it gets to trying to join when selecting from the Album table there is no SiteTree.ID column.</p>
  
  <p>I've also tried this:</p>
  
  <pre><code>SELECT SiteTree.*, Page.*, AlbumItem.*, Album.*
  FROM SiteTree LEFT JOIN Page ON SiteTree.ID = Page.ID, AlbumItem, Album
  </code></pre>
  
  <p>Which returns about 20 Rows and I know there should only be 2 based on the where clause.  Infact there about 10 copies of each result row</p>
  
  <p>There where clause is as follows:</p>
  
  <pre><code>WHERE (
      (
          AlbumItem.ClassName = 'AlbumItem' OR 
          Album.ClassName = 'Album' OR 
          SiteTree.ClassName = 'Page' OR 
          SiteTree.ClassName = 'HomePage' OR 
          SiteTree.ClassName = 'NewsCategory' OR
          SiteTree.ClassName = 'NewsArticle' OR
          SiteTree.ClassName = 'CartPage' OR
          SiteTree.ClassName = 'Product' OR
          SiteTree.ClassName = 'ProductGroup' OR
          SiteTree.ClassName = 'MemberProfilePage' OR
          SiteTree.ClassName = 'SubscriptionPage' OR
          SiteTree.ClassName = 'ErrorPage' OR
          SiteTree.ClassName = 'RedirectorPage' OR
          SiteTree.ClassName = 'VirtualPage' OR
          SiteTree.ClassName = 'UserDefinedForm' OR
          SiteTree.ClassName = 'CheckoutPage' OR
          SiteTree.ClassName = 'OrderConfirmationPage' OR
          SiteTree.ClassName = 'TagPage'
      ) AND (
         INSTR(Page.Tags,'x') OR
         INSTR(AlbumItem.Tags,'x') OR
         INSTR(Album.Tags,'x')
      )
  )
  </code></pre>
  
  <p>Reducing the query to this produces the correct result, but it wont work for the other tables as well:</p>
  
  <pre><code>SELECT SiteTree.*, Page.*
  FROM SiteTree
  LEFT JOIN Page ON SiteTree.ID = Page.ID
  </code></pre>
  
  <p>What I need to know is if what I am trying to doing is possible without resorting to unions?</p>