SELECT *, CASE WHEN `sub_cat`= "post office" AND `cat` = "community" AND `locality` = "enterprise" AND `logo_file_name` IS NOT NULL THEN 10 WHEN `sub_cat`= "post office" AND `cat` = "community" AND `locality` = "enterprise" AND `logo_file_name` IS NULL THEN 9 WHEN `sub_cat`= "post office" AND `cat` = "community" AND `locality` IS NULL AND `logo_file_name` IS NOT NULL THEN 10 WHEN `sub_cat`= "post office" AND `cat` = "community" AND `locality` IS NULL AND `logo_file_name` IS NULL THEN 9 WHEN `sub_cat` IS NULL AND `cat` IS NULL AND `locality` IS NULL AND `logo_file_name` IS NULL THEN 0 END as `rank` FROM `wp_48_slides` WHERE (locality IN ("enterprise") OR locality IS NULL) AND (cat = "community" OR cat IS NULL) AND name NOT IN ("home-top", "home-bot") AND (sub_cat = "post office" OR sub_cat IS NULL) AND active = 1 ORDER BY `rank` DESC LIMIT 20 [6] matching rows / [0.00 msec] Blog ID 48 Blah
COMMUNITY