SELECT inventory_items.*, inventory_items.id AS inventory_id, inventory_categories.name AS category_name FROM inventory_items JOIN inventory_category_item ON (inventory_category_item.item_id = inventory_items.id) JOIN inventory_categories ON (inventory_categories.id = inventory_category_item.category_id) WHERE ( show_item = 1 ) AND ( inventory_categories.name LIKE '%big sky%' OR inventory_items.name LIKE '%big sky%' OR sku LIKE '%big sky%' OR brand LIKE '%big sky%' OR inventory_items.description LIKE '%big sky%' OR features LIKE '%big sky%' OR specs LIKE '%big sky%' ) GROUP BY inventory_items.name ORDER BY stock_status ASC