SELECT *, CASE WHEN `sub_cat`= "lawn services" AND `cat` = "shopping" AND `locality` = "galveston" THEN 7 WHEN `sub_cat` IS NULL AND `cat` = "home-services" AND `locality` = "galveston" THEN 6 WHEN `sub_cat` IS NULL AND `cat` IS NULL AND `locality` = "galveston" THEN 5 WHEN `sub_cat` IS NULL AND `cat` IS NULL AND `locality` IS NULL THEN 0 END as `rank` FROM `wp_37_slides` WHERE (locality = "galveston" OR locality IS NULL) AND (cat = "home-services" OR cat IS NULL) AND (sub_cat = "lawn services" OR sub_cat IS NULL) ORDER BY `rank` DESC LIMIT 20 [18] matching rows / [0.00 msec] Blog ID 37 Blah
HOME SERVICES