title: SQL left joining tables with ambiguous column names
body: <p>I need to left join a few tables in a query where the column names are ambiguous.</p>
  
  <p><strong>ListingCategory_Listings:</strong></p>
  
  <blockquote>
    <p>ID | ListingCategoryID | ListingID | ..</p>
  </blockquote>
  
  <p><strong>SiteTree_Live:</strong></p>
  
  <blockquote>
    <p>ID | ClassName | Title | Content | ..</p>
  </blockquote>
  
  <p><strong>ListingCategory:</strong></p>
  
  <blockquote>
    <p>ID | IconID</p>
  </blockquote>
  
  <p><strong>File:</strong></p>
  
  <blockquote>
    <p>ID | ClassName | Name | Title | Filename | ..</p>
  </blockquote>
  
  <p>I have the query:</p>
  
  <pre><code>SELECT * FROM ListingCategory_Listings 
  LEFT JOIN Listing ON ListingCategory_Listings.ListingID = Listing.ID 
  LEFT JOIN SiteTree_Live ON Listing.ID = SiteTree_Live.ID 
  LEFT JOIN ListingCategory ON ListingCategory_Listings.ListingCategoryID = ListingCategory.ID 
  LEFT JOIN File ON ListingCategory.IconID = File.ID
  </code></pre>
  
  <p>Both the listing and listing category data is stored in the SiteTree_Live table, when my records are returned, obviously, the Title, ID, Content and other ambiguous fields are returned under the heading Title, ID, Content.</p>
  
  <p>I need to access both the Listing Title and The Listing Category Title and other specific information. If they had their data stored in different tables I could use select Listing.Title AS lTitle but how can I do something similar in this situation?</p>