SELECT * FROM `cart_product` JOIN `cart_category` ON `cart_category`.`cat_id` = `cart_product`.`prod_cat_id` WHERE `prod_type` = 'Main' AND `cat_name` LIKE '%%' ESCAPE '!' OR `prod_name` LIKE '%%' ESCAPE '!'