SELECT 
  company_descriptions.*, 
  companies.*, 
  cscart_vendor_plan_descriptions.plan, 
  cscart_seo_names.name as seo_name, 
  cscart_seo_names.path as seo_path, 
  AVG(
    cscart_discussion_rating.rating_value
  ) AS average_rating, 
  CONCAT(
    companies.company_id, 
    '_', 
    IF (
      cscart_discussion_rating.thread_id, 
      cscart_discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids 
FROM 
  cscart_companies AS companies 
  LEFT JOIN cscart_company_descriptions AS company_descriptions ON company_descriptions.company_id = companies.company_id 
  AND company_descriptions.lang_code = 'en' 
  LEFT JOIN cscart_vendor_plan_descriptions ON companies.plan_id = cscart_vendor_plan_descriptions.plan_id 
  AND cscart_vendor_plan_descriptions.lang_code = 'en' 
  LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = 44 
  AND cscart_seo_names.type = 'm' 
  AND cscart_seo_names.dispatch = '' 
  AND cscart_seo_names.lang_code = 'en' 
  LEFT JOIN cscart_discussion ON cscart_discussion.object_id = companies.company_id 
  AND cscart_discussion.object_type = 'M' 
  LEFT JOIN cscart_discussion_posts ON cscart_discussion_posts.thread_id = cscart_discussion.thread_id 
  AND cscart_discussion_posts.status = 'A' 
  LEFT JOIN cscart_discussion_rating ON cscart_discussion.thread_id = cscart_discussion_rating.thread_id 
  AND cscart_discussion_rating.post_id = cscart_discussion_posts.post_id 
WHERE 
  companies.company_id = 44

Query time 0.00077

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.10"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "companies",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "company_id"
          ],
          "key_length": "4",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "6K"
          },
          "used_columns": [
            "company_id",
            "status",
            "company",
            "lang_code",
            "address",
            "city",
            "state",
            "country",
            "zipcode",
            "email",
            "phone",
            "url",
            "storefront",
            "secure_storefront",
            "entry_page",
            "redirect_customer",
            "countries_list",
            "timestamp",
            "shippings",
            "logos",
            "request_user_id",
            "request_account_name",
            "request_account_data",
            "tax_number",
            "registered_from_storefront_id",
            "plan_id",
            "pre_moderation",
            "pre_moderation_edit",
            "pre_moderation_edit_vendors",
            "suspend_date",
            "grace_period_start",
            "last_time_suspended",
            "last_debt_notification_time",
            "override_delivery_days",
            "delivery_days",
            "stripe_connect_account_id",
            "stripe_connect_account_type",
            "paypal_commerce_platform_account_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "company_descriptions",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "company_id",
            "lang_code"
          ],
          "key_length": "10",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "company_id",
            "lang_code",
            "company_description",
            "terms",
            "i18n_company",
            "i18n_address",
            "i18n_city"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_vendor_plan_descriptions",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "plan_id",
            "lang_code"
          ],
          "key_length": "10",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "792"
          },
          "used_columns": [
            "plan_id",
            "lang_code",
            "plan"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_seo_names",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY",
            "dispatch"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "object_id",
            "type",
            "dispatch",
            "lang_code"
          ],
          "key_length": "206",
          "ref": [
            "const",
            "const",
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.10",
            "prefix_cost": "0.35",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "name",
            "object_id",
            "type",
            "dispatch",
            "path",
            "lang_code"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion",
          "access_type": "const",
          "possible_keys": [
            "object_id"
          ],
          "key": "object_id",
          "used_key_parts": [
            "object_id",
            "object_type"
          ],
          "key_length": "6",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.10",
            "prefix_cost": "0.70",
            "data_read_per_join": "24"
          },
          "used_columns": [
            "thread_id",
            "object_id",
            "object_type"
          ]
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion_posts",
          "access_type": "ref",
          "possible_keys": [
            "thread_id",
            "thread_id_2"
          ],
          "key": "thread_id",
          "used_key_parts": [
            "thread_id"
          ],
          "key_length": "3",
          "ref": [
            "wearethehelpful_scalesta_net.cscart_discussion.thread_id"
          ],
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 2,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.50",
            "eval_cost": "0.20",
            "prefix_cost": "1.40",
            "data_read_per_join": "896"
          },
          "used_columns": [
            "post_id",
            "thread_id",
            "status"
          ],
          "attached_condition": "<if>(is_not_null_compl(cscart_discussion_posts), (`wearethehelpful_scalesta_net`.`cscart_discussion_posts`.`status` = 'A'), true)"
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion_rating",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "thread_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "post_id"
          ],
          "key_length": "3",
          "ref": [
            "wearethehelpful_scalesta_net.cscart_discussion_posts.post_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 2,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.50",
            "eval_cost": "0.20",
            "prefix_cost": "2.10",
            "data_read_per_join": "32"
          },
          "used_columns": [
            "rating_value",
            "post_id",
            "thread_id"
          ],
          "attached_condition": "<if>(is_not_null_compl(cscart_discussion_rating), (`wearethehelpful_scalesta_net`.`cscart_discussion_rating`.`thread_id` = `wearethehelpful_scalesta_net`.`cscart_discussion`.`thread_id`), true)"
        }
      }
    ]
  }
}

Result

company_id lang_code company_description terms i18n_company i18n_address i18n_city status company address city state country zipcode email phone url storefront secure_storefront entry_page redirect_customer countries_list timestamp shippings logos request_user_id request_account_name request_account_data tax_number registered_from_storefront_id plan_id pre_moderation pre_moderation_edit pre_moderation_edit_vendors suspend_date grace_period_start last_time_suspended last_debt_notification_time override_delivery_days delivery_days stripe_connect_account_id stripe_connect_account_type paypal_commerce_platform_account_id plan seo_name seo_path average_rating company_thread_ids
44 en <p>Company Name: TONIC London Limited</p> <p>Company Registration Number: 15327442</p> <p>Registered Office: 7 Jardine House, Bessborough Road, Harrow, Middlesex, HA1 3EX, United Kingdom</p> <p>Email Address:&nbsp;<a href="mailto:hello@your-tonic.com" target="_blank">hello@your-tonic.com</a></p> <p>Please read these Terms carefully before placing an order or using the services on our Site.</p> <h2>1. Products and Services</h2> <p>TONIC London Limited designs and manufactures high quality patient wear clothing and accessories intended for treatment and recovery. Our product range includes, but is not limited to, hospital pajamas, patient gowns, dressing gowns, slings, treatment tracksuits, drain gowns, cashmere socks, and shawls.</p> <p>Product Availability:</p> <p>All products displayed on the Site are subject to availability. We make every effort</p> <p>to ensure accurate stock levels and product descriptions, but we reserve the right to change product availability or discontinue items at any time without notice.</p> <p>Product Descriptions:</p> <p>We strive to provide accurate descriptions of our products, including material composition,</p> <p>care instructions, and design features. However, slight variations in color, size, or appearance may occur due to lighting, screen settings, or manufacturing processes.</p> <h2>2. Ordering and Payment</h2> <p>Placing an Order:</p> <p>By placing an order on the Site, you make an offer to purchase the products in your cart. Orders are subject to acceptance by us, and we reserve the right to refuse any order at our discretion.</p> <p>Order Confirmation:</p> <p>Once your order is placed, you will receive an email confirmation acknowledging receipt of your order. This is not an acceptance of your offer to purchase, but a confirmation that we have received your order.</p> <p>Payment:</p> <p>All orders must be paid for in full before they are shipped. We accept payment by major</p> <p>credit cards, debit cards, and other payment methods as specified on the checkout page.&nbsp;</p> <p>Processing is handled through secure payment providers, and we do not store payment information.</p> <p>Pricing:</p> <p>All prices on the Site are in GBP (£) and include VAT (where applicable). Shipping and handling costs are not included in the price of products and will be calculated at checkout.</p> <p>Prices may change from time to time, but the price you are charged will be the price at the time of your order.</p> <h2>3. Shipping and Delivery</h2> <p>Shipping Methods:</p> <p>We offer standard shipping options. Shipping costs will be calculated at checkout based on the delivery address and selected shipping method.</p> <p>Delivery Times:</p> <p>We aim to dispatch orders within 2 business days. Delivery times will depend on your location and the shipping method chosen at checkout. Please note that delivery times are estimates and may vary due to factors beyond our control, such as postal delays or customs processing.</p> <p>International Shipping:</p> <p>We currently do not offer international shipping.</p> <p>Northern Ireland and Crown Dependencies:</p> <p>We ship to these locations but please note, there may be additional delivery times and charges.</p> <p>Delivery Issues:</p> <p>If your order does not arrive within the expected time frame, please use the tracking tool found in the&nbsp;<a href="https://your-tonic.com/pages/shipping-returns" target="_blank" data-saferedirecturl="https://www.google.com/url?q=https://your-tonic.com/pages/shipping-returns&source=gmail&ust=1766001207962000&usg=AOvVaw3sezKXHLsi1OtPy69jbUlT">Shipping & Returns page</a>&nbsp;for the shipments latest status or speak to us in the chat function. We will assist you in tracking your order and / or arranging a replacement if necessary.</p> <h2>4. Returns and Exchanges</h2> <p>Returns Policy:</p> <p>We want you to be fully satisfied with your purchase. If for any reason you are not happy with your order, you can return it within 14 days of receipt, provided the item is unused, unworn, and in its original packaging with tags intact.</p> <p>Return Process:</p> <p>To initiate a return, please use the tracking tool found in the&nbsp;<a href="https://your-tonic.com/pages/shipping-returns" target="_blank" data-saferedirecturl="https://www.google.com/url?q=https://your-tonic.com/pages/shipping-returns&source=gmail&ust=1766001207962000&usg=AOvVaw3sezKXHLsi1OtPy69jbUlT">Shipping & Returns page</a>&nbsp;or speak to us in the chat function. Tell us your order details and we will provide instructions on how to return your item. You will be responsible for the cost of return shipping, unless the item is faulty or the incorrect item. When you return your goods, please retain proof of posting from your shipper, without this we cannot be responsible for any items that fail to reach us or is damaged in transit. Once a return is received by our UK warehouse, it will undergo a quality review. Once the items have passed inspection, we will process the refund applied to your original method of payment. Please allow up to 10 business days.</p> <p>Returns Address:</p> <p>TONIC London Ltd C/O The Brand Hangar Unit 12 Saxon Park Bletchley MK1 1QU</p> <p>Faulty or Incorrect Items:</p> <p>If you receive a faulty or incorrect item, please contact us immediately and we’ll review. Subject to approval, we will arrange for a return of the item and issue a full refund or replacement as appropriate.</p> TONIC A TONIC hello@your-tonic.com none Y 1753805533 39 0 a:4:{s:14:"company_fields";a:6:{i:37;s:6:"Sophie";i:38;s:7:"Fawcett";i:53;s:36:"Modern Medical Apparel & Accessories";i:54;s:139:"TONIC hosts a 27+ product collection that would likely be suitable for the 'illness + recovery' section of the We are The Helpful platform.";i:55;s:43:"UK based women between the ages of 35 - 60.";i:56;s:90:"Functional apparel and accessories designed for those going through treatment or recovery.";}s:15:"admin_firstname";s:6:"Sophie";s:14:"admin_lastname";s:7:"Fawcett";s:6:"fields";a:0:{}} 474245286 1 10 N N N 0 0 0 0 N 0 acct_1SNFClQPW1RI47wg S Launch - 20% tonic 44_0