Products meeting the search criteria
select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id) left join specials s on p.products_id = s.products_id , products_description pd, categories c, products_to_categories p2c, categories_description cd where c.hidden = '0' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and cd.categories_id = c.categories_id and (p.products_quantity > '0' or p.products_date_available >= (now() - interval 1 day)) and p.paypal_blocked = 0 and ((pd.products_name regexp '\\bhigo\\b' or pd.products_subtitle regexp '\\bhigo\\b' or p.products_model regexp '\\bhigo\\b' or m.manufacturers_name regexp '\\bhigo\\b' or p.products_id in (select product_id from products_tags where tag_id regexp '\\bhigo\\b') ) and (pd.products_name regexp '\\bzuiki\\b' or pd.products_subtitle regexp '\\bzuiki\\b' or p.products_model regexp '\\bzuiki\\b' or m.manufacturers_name regexp '\\bzuiki\\b' or p.products_id in (select product_id from products_tags where tag_id regexp '\\bzuiki\\b') ))
select distinct p.products_quantity, p.products_date_available, p.products_image, m.manufacturers_id, p.products_id, pd.products_name, pd.products_subtitle, pd.products_subtitle, p.products_price, p.products_base_price, p.products_tax_class_id, if(s.status, s.specials_new_products_price, null) as specials_new_products_price, if(s.status, s.specials_new_products_price, p.products_price) as final_price from products p left join manufacturers m using(manufacturers_id) left join specials s on p.products_id = s.products_id , products_description pd, categories c, products_to_categories p2c, categories_description cd where c.hidden = '0' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and cd.categories_id = c.categories_id and (p.products_quantity > '0' or p.products_date_available >= (now() - interval 1 day)) and p.paypal_blocked = 0 and ((pd.products_name regexp '\\bhigo\\b' or pd.products_subtitle regexp '\\bhigo\\b' or p.products_model regexp '\\bhigo\\b' or m.manufacturers_name regexp '\\bhigo\\b' or p.products_id in (select product_id from products_tags where tag_id regexp '\\bhigo\\b') ) and (pd.products_name regexp '\\bzuiki\\b' or pd.products_subtitle regexp '\\bzuiki\\b' or p.products_model regexp '\\bzuiki\\b' or m.manufacturers_name regexp '\\bzuiki\\b' or p.products_id in (select product_id from products_tags where tag_id regexp '\\bzuiki\\b') )) group by (p.products_id) order by p.products_date_added desc, pd.products_name, p.products_id
Back