Query SELECT `listings`.`sid` as `object_sid`, if( COUNT( `complex_enum` ) >0, COUNT( * ) - COUNT( `complex_enum` ) +1, COUNT( * ) ) `count` FROM `listings` JOIN `listings_properties` ON `listings`.`sid` = `listings_properties`.`object_sid` WHERE 1 AND `listings`.`active` = '1' AND (
(`listings` . `access_type` = 'everyone') OR
(`listings` . `access_type` = 'only' AND FIND_IN_SET('', `listings` . `access_list`) ) OR
(`listings` . `access_type` = 'except' AND (FIND_IN_SET('', `listings` . `access_list`) = 0 OR FIND_IN_SET('', `listings` . `access_list`) IS NULL) )
) GROUP BY `listings_properties`.`object_sid` ORDER BY priority desc, CompanyName ASC :
Unknown column 'CompanyName' in 'order clause'
There are no postings meeting the criteria you specified