SELECT 
  cscart_products.*, 
  cscart_product_descriptions.*, 
  MIN(
    IF(
      cscart_product_prices.percentage_discount = 0, 
      cscart_product_prices.price, 
      cscart_product_prices.price - (
        cscart_product_prices.price * cscart_product_prices.percentage_discount
      )/ 100
    )
  ) as price, 
  GROUP_CONCAT(
    CASE WHEN (
      cscart_products_categories.link_type = 'M'
    ) THEN CONCAT(
      cscart_products_categories.category_id, 
      'M'
    ) ELSE cscart_products_categories.category_id END 
    ORDER BY 
      cscart_categories.storefront_id IN (0, 1) DESC, 
      (
        cscart_products_categories.link_type = 'M'
      ) DESC, 
      cscart_products_categories.category_position ASC, 
      cscart_products_categories.category_id ASC
  ) as category_ids, 
  popularity.total as popularity, 
  company_descr.i18n_company as company_name, 
  cscart_products.is_returnable, 
  cscart_products.return_period, 
  cscart_product_sales.amount as sales_amount, 
  cscart_seo_names.name as seo_name, 
  cscart_seo_names.path as seo_path, 
  MIN(point_prices.point_price) as point_price, 
  cscart_discussion.type as discussion_type, 
  cscart_product_review_prepared_data.average_rating average_rating, 
  cscart_product_review_prepared_data.reviews_count product_reviews_count 
FROM 
  cscart_products 
  LEFT JOIN cscart_product_prices ON cscart_product_prices.product_id = cscart_products.product_id 
  AND cscart_product_prices.lower_limit = 1 
  AND cscart_product_prices.usergroup_id IN (0, 0, 1) 
  LEFT JOIN cscart_product_descriptions ON cscart_product_descriptions.product_id = cscart_products.product_id 
  AND cscart_product_descriptions.lang_code = 'en' 
  LEFT JOIN cscart_company_descriptions as company_descr ON company_descr.company_id = cscart_products.company_id 
  AND company_descr.lang_code = 'en' 
  LEFT JOIN cscart_companies as companies ON companies.company_id = cscart_products.company_id 
  INNER JOIN cscart_products_categories ON cscart_products_categories.product_id = cscart_products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND (
    cscart_products.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_products.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_products.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  AND cscart_products.status IN ('A', 'H') 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = cscart_products.product_id 
  LEFT JOIN cscart_product_sales ON cscart_product_sales.product_id = cscart_products.product_id 
  AND cscart_product_sales.category_id = 318 
  LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = 338 
  AND cscart_seo_names.type = 'p' 
  AND cscart_seo_names.dispatch = '' 
  AND cscart_seo_names.lang_code = 'vn' 
  LEFT JOIN cscart_product_point_prices as point_prices ON point_prices.product_id = cscart_products.product_id 
  AND point_prices.lower_limit = 1 
  AND point_prices.usergroup_id IN (0, 0, 1) 
  LEFT JOIN cscart_discussion ON cscart_discussion.object_id = cscart_products.product_id 
  AND cscart_discussion.object_type = 'P' 
  LEFT JOIN cscart_product_review_prepared_data ON cscart_product_review_prepared_data.product_id = cscart_products.product_id 
  AND cscart_product_review_prepared_data.storefront_id = 0 
WHERE 
  cscart_products.product_id = 338 
  AND (
    companies.status IN ('A') 
    OR cscart_products.company_id = 0
  ) 
GROUP BY 
  cscart_products.product_id

Query time 0.00150

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "point_prices",
          "access_type": "system",
          "possible_keys": ["unique_key", "src_k"],
          "rows": 0,
          "filtered": 0,
          "const_row_not_found": true
        }
      },
      {
        "table": {
          "table_name": "cscart_products",
          "access_type": "const",
          "possible_keys": ["PRIMARY", "status"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "popularity",
          "access_type": "const",
          "possible_keys": ["PRIMARY", "total"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_product_sales",
          "access_type": "const",
          "possible_keys": ["PRIMARY", "pa"],
          "key": "PRIMARY",
          "key_length": "6",
          "used_key_parts": ["category_id", "product_id"],
          "ref": ["const", "const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion",
          "access_type": "const",
          "possible_keys": ["object_id"],
          "key": "object_id",
          "key_length": "6",
          "used_key_parts": ["object_id", "object_type"],
          "ref": ["const", "const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_product_review_prepared_data",
          "access_type": "const",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "7",
          "used_key_parts": ["product_id", "storefront_id"],
          "ref": ["const", "const"],
          "rows": 0,
          "filtered": 0,
          "unique_row_not_found": true
        }
      },
      {
        "table": {
          "table_name": "cscart_product_prices",
          "access_type": "ref",
          "possible_keys": [
            "usergroup",
            "product_id",
            "lower_limit",
            "usergroup_id"
          ],
          "key": "product_id",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_product_prices.lower_limit = 1 and cscart_product_prices.usergroup_id in (0,0,1))"
        }
      },
      {
        "table": {
          "table_name": "cscart_product_descriptions",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "product_id"],
          "key": "product_id",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_product_descriptions.lang_code = 'en')"
        }
      },
      {
        "table": {
          "table_name": "company_descr",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "10",
          "used_key_parts": ["company_id", "lang_code"],
          "ref": ["const", "const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(company_descr.lang_code = 'en')"
        }
      },
      {
        "table": {
          "table_name": "companies",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["company_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(companies.`status` = 'A')"
        }
      },
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["demov2026.cscart_products_categories.category_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "cscart_categories.storefront_id in (0,1) and (cscart_categories.usergroup_ids = '' or find_in_set(0,cscart_categories.usergroup_ids) or find_in_set(1,cscart_categories.usergroup_ids)) and cscart_categories.`status` in ('A','H')"
        }
      },
      {
        "table": {
          "table_name": "cscart_seo_names",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "dispatch"],
          "key": "PRIMARY",
          "key_length": "206",
          "used_key_parts": ["object_id", "type", "dispatch", "lang_code"],
          "ref": ["const", "const", "const", "const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_seo_names.`type` = 'p' and cscart_seo_names.dispatch = '' and cscart_seo_names.lang_code = 'vn')"
        }
      }
    ]
  }
}

Result

product_id product_code product_type status company_id list_price amount weight length width height shipping_freight low_avail_limit timestamp updated_timestamp usergroup_ids is_edp edp_shipping unlimited_download tracking free_shipping zero_price_action is_pbp is_op is_oper is_returnable return_period avail_since out_of_stock_actions localization min_qty max_qty qty_step list_qty_count tax_ids age_verification age_limit options_type exceptions_type details_layout shipping_params show_videos_before_images autoplay_videos facebook_obj_type parent_product_id buy_now_url units_in_product show_price_per_x_units ab__stickers_manual_ids ab__stickers_generated_ids lang_code product shortname short_description full_description meta_keywords meta_description search_words page_title age_warning_message promo_text unit_name price category_ids popularity company_name sales_amount seo_name seo_path point_price discussion_type average_rating product_reviews_count
338 HANHPHUC P A 3 620000.00 100 0.000 0 0 0 0.00 0 1782532944 1784353449 0 N N N N Y N N Y 10 0 N N 0 default a:5:{s:16:"min_items_in_box";i:0;s:16:"max_items_in_box";i:0;s:10:"box_length";i:0;s:9:"box_width";i:0;s:10:"box_height";i:0;} N N activity 0 0.000 0.000 en FOUR SEASONS GIFT BOX <p>Hộp quà Bốn Mùa K Coffee 547g (bộ) – gồm cà phê rang xay nguyên chất & K Filter phin giấy. Quà tặng sang trọng. Chính hãng K Coffee.</p> <p><span style="font-size: 40px; font-weight: 700;">K COFFEE Four Seasons Gift Box – A Premium Coffee Gift for Every Occasion</span></p> <p><b>Experience the Taste of Vietnam in One Elegant Gift Box</b></p> <p>The K COFFEE Four Seasons Gift Box is a carefully curated collection designed to celebrate the beauty of every season through premium Vietnamese coffee. Combining four distinctive products in one luxurious package, this gift set offers a complete coffee experience for both seasoned coffee lovers and newcomers alike.</p> <p>Whether you're celebrating holidays, birthdays, anniversaries, or corporate milestones, the Four Seasons Gift Box is an elegant way to express appreciation and create lasting impressions.</p> <h2>What's Inside the Four Seasons Gift Box?</h2> <h3>Premium Roasted Ground Coffee</h3> <p>Made from carefully selected Vietnamese coffee beans, this roasted coffee delivers a rich body, balanced bitterness, and a naturally smooth finish. Every cup reflects K COFFEE's commitment to quality and authentic coffee craftsmanship.</p> <h3>K Filter Drip Coffee</h3> <p>Enjoy café-quality coffee anywhere with convenient single-serve drip bags. Simply place the filter over your cup, pour hot water, and enjoy freshly brewed coffee within minutes&mdash;perfect for travel, the office, or home.</p> <h3>K Delight Instant Coffee 3-in-1</h3> <p>A smooth blend of premium coffee, milk, and sugar that creates a creamy and well-balanced cup. Ideal for busy mornings or whenever you need a quick coffee break without compromising quality.</p> <h3>Cascara Tea</h3> <p>Crafted from the dried skins of ripe Arabica coffee cherries, Cascara Tea offers a naturally refreshing beverage with delicate fruit notes and a clean finish. It provides a unique alternative for those looking to explore another side of the coffee plant.</p> <h2>Why Choose the K COFFEE Four Seasons Gift Box?</h2> <h3>Premium Vietnamese Coffee</h3> <p>Every product is made from carefully selected coffee beans sourced from Vietnam's renowned coffee-growing regions and processed under strict quality standards.</p> <h3>Elegant Gift Presentation</h3> <p>Inspired by the four seasons&mdash;Spring, Summer, Autumn, and Winter&mdash;the beautifully designed gift box represents warmth, appreciation, and meaningful connections.</p> <h3>A Variety of Coffee Experiences</h3> <p>Instead of offering just one coffee style, this collection allows recipients to enjoy roasted coffee, drip coffee, instant coffee, and Cascara tea in a single premium package.</p> <h3>Perfect for Every Occasion</h3> <ul><li>The Four Seasons Gift Box is suitable for:</li><li>Corporate gifts</li><li>Client appreciation gifts</li><li>Employee rewards</li><li>Holiday gifts</li><li>Birthday presents</li><li>Housewarming gifts</li><li>Family gatherings</li><li>Coffee enthusiasts</li></ul> <h3>Premium Quality You Can Trust</h3> <p>K COFFEE follows a comprehensive Farm-to-Cup production process, ensuring quality at every stage&mdash;from sourcing premium coffee cherries to roasting, packaging, and final delivery.</p> <p>The products are manufactured according to internationally recognized food safety and quality standards, delivering consistent taste and premium quality in every package.</p> <h2>Product Information</h2> <ul><li>Brand: K COFFEE</li><li>Origin: Vietnam</li><li>Net Weight: 547 g</li><li>Gift Box Includes:</li><li>Premium Roasted Ground Coffee – 227 g</li><li>K Filter Drip Coffee – 50 g</li><li>K Delight Instant Coffee 3-in-1 – 170 g</li><li>Cascara Tea – 100 g</li><li>Shelf Life: 18 months</li></ul> <h2>Brewing Instructions</h2> <ul><li>Roasted Coffee: Brew using a Vietnamese phin filter, French press, pour-over, or espresso machine according to your preference.</li><li>Drip Coffee: Open the drip bag, place it over your cup, slowly pour hot water (90–95°C), and enjoy freshly brewed coffee.</li><li>Instant Coffee: Mix one sachet with hot water, stir well, and serve immediately.</li><li>Cascara Tea: Steep in hot water for 4–6 minutes before serving.</li></ul> <h2>Storage Instructions</h2> <ul><li>Store in a cool, dry place.</li><li>Keep away from direct sunlight.</li><li>Reseal the package tightly after opening.</li><li>Avoid exposure to moisture.</li></ul><h2>Why Do Coffee Lovers Choose K COFFEE?</h2> <ul><li>Premium Vietnamese coffee made from carefully selected beans</li><li>Beautifully designed luxury gift packaging</li><li>Four unique coffee experiences in one collection</li><li>Suitable for personal and corporate gifting</li><li>Convenient brewing options for different lifestyles</li><li>Crafted under international quality standards</li></ul> <p></p><p></p> <p></p> quà tặng cà phê, set quà cà phê, hộp quà cà phê cao cấp, quà tết cà phê, quà tặng K Coffee Hộp quà Bốn Mùa K Coffee 547g (bộ) – gồm cà phê rang xay nguyên chất & K Filter phin giấy. Quà tặng sang trọng. Chính hãng K Coffee. quà tặng cà phê, set quà cà phê, hộp quà cà phê cao cấp, quà tết cà phê, quà tặng K Coffee Hộp Quà Cà Phê K Coffee Bốn Mùa 547g (bộ) | K Coffee 620000.00000000 318M 2260 K COFFEE 1 hop-qua-ca-phe-bon-mua-547g 318 D