You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON .BrandID=motors_listings.BrandID LEFT JOIN (Select ListingID,COUNT(Ph' at line 6Failed Query: SELECT motors_listings.*,IFNULL(TotPhotos,0) TotPhotos,IFNULL(TotVideos,0) TotVideos, PhotoName,BrandName,CurrentPlanID,PremiumDisplay FROM motors_listings INNER JOIN motors_users users On users.UserID = motors_listings.UserID INNER JOIN motors_listing_plans plans On plans.PlanID=users.CurrentPlanID LEFT JOIN ON .BrandID=motors_listings.BrandID LEFT JOIN (Select ListingID,COUNT(PhotoID) TotPhotos From motors_listing_photos Group By ListingID) photos On motors_listings.ListingID=photos.ListingID LEFT JOIN (Select ListingID,COUNT(VideoID) TotVideos From motors_listing_videos Group By ListingID) videos On motors_listings.ListingID=videos.ListingID LEFT JOIN motors_listing_photos photo On motors_listings.ListingID=photo.ListingID And IsPrimary=1 WHERE motors_listings.Status=1 And motors_listings.UserID=416 Order By PostedOn DESC
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON .BrandID=motors_listings.BrandID LEFT JOIN (Select ListingID,COUNT(Ph' at line 6