Error in count items query! SELECT count(*) as itemNum FROM leonardo_flights,leonardo_waypoints WHERE (1=1) AND cat=1 AND DATE_FORMAT(DATE,'%Y') = 2013 AND ( excludeFrom & 1 ) = 0 AND userID>0 AND (private=0 OR private=4 ) AND leonardo_flights.takeoffID=leonardo_waypoints.ID AND leonardo_waypoints.countryCode='CA'