SELECT *, CASE WHEN `sub_cat`= "residential" AND `cat` = "shopping" AND `locality` = "akron" THEN 7 WHEN `sub_cat` IS NULL AND `cat` = "local-real-estate" AND `locality` = "akron" THEN 6 WHEN `sub_cat` IS NULL AND `cat` IS NULL AND `locality` = "akron" THEN 5 WHEN `sub_cat` IS NULL AND `cat` IS NULL AND `locality` IS NULL THEN 0 END as `rank` FROM `wp_16_slides` WHERE (locality = "akron" OR locality IS NULL) AND (cat = "local-real-estate" OR cat IS NULL) AND (sub_cat = "residential" OR sub_cat IS NULL) ORDER BY `rank` DESC LIMIT 20 [6] matching rows / [0.00 msec] Blog ID 16 Blah
REAL ESTATE