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 = 4 
  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 = 4

Query time 0.00561

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
4 en <p><br /></p> <p><br /><br /></p> <p><span style="font-size:24px;font-weight:700;">We are The Helpful Retail Terms and Conditions</span><br></p> <h4>1. Introduction</h4> <ul><li>These Terms and Conditions govern the purchase and use of products purchased directly from We are The Helpful Ltd SC769063 ("we," "us," or "our"). By placing an order with us, you ("Customer") agree to be bound by these Terms.</li></ul> <h4>2. Orders</h4> <ul><li>All orders are subject to acceptance and availability.</li><li>Prices for products are as quoted on our website and may change without prior notice. The price charged will be the price at the time of purchase.</li><li>Orders are considered accepted when we send an email to you confirming that the order has been ‘completed’.</li></ul> <h4>3. Product Information</h4> <ul><li>We strive to ensure that product descriptions, images, and information provided on our website are accurate. However, slight variations in color or packaging may occur.</li><li>The ingredients and instructions for use are listed on the product packaging. Customers are responsible for reading and following all usage instructions.</li></ul> <h4>5. Shipping and Delivery</h4> <ul><li>We offer delivery within the UK using Royal Mail.</li><li>Standard delivery times are 3-5 business days from the date of dispatch. Delivery times are estimates and not guaranteed.</li><li>Shipping costs are calculated at checkout based on the weight and value of the order.</li><li>Free shipping may be available for orders over a specified amount as detailed on the product page.</li><li>Risk in the goods passes to you upon delivery. Title in the goods will not pass to you until we receive full payment.</li></ul> <h4>6. Returns and Refunds</h4> <ul><li><strong>Right to Cancel:&nbsp;</strong>In line with UK Consumer Contracts Regulations (“Cooling Off Period”), you have the right to cancel your order within 14 days of receiving your products, provided they are unopened, unused, and in their original packaging.</li></ul><ul><li><strong>How to Return:&nbsp;</strong>To start a return, please email us at <strong>help@wearethehelpful.com&nbsp;</strong>with your order details. We’ll share the return instructions with you. Unless the item is faulty or misdescribed, return postage is the responsibility of the customer. We recommend using tracked delivery so it’s safe both ways.</li></ul><ul><li><strong>Refunds:&nbsp;</strong>Once we’ve received and inspected your returned item, we’ll process your refund within <strong>7 days</strong>, back to your original payment method. You’ll receive a confirmation email once your refund has been completed.</li></ul><ul><li><strong>Damaged or Faulty Items:&nbsp;</strong>If your order arrives damaged or faulty, please contact us within <strong>7 days of delivery</strong>, including photos where possible, and we’ll arrange a replacement or refund at no cost to you.</li></ul><ul><li><strong>Items We Can’t Take Back:&nbsp;</strong>Some items are non-returnable for hygiene, safety, or bespoke reasons, unless faulty:</li></ul><ul><li>Anything personalised or made to your specific requirements (not suitable for resale).</li></ul><ol> <li> <p>Perishable products (like food).</p> </li> <li> <p>Opened or used products, unless defective.</p> </li> <li> <p>Personal items with hygiene seals (such as skincare, cosmetics, or certain clothing items) once the seal is broken.</p></li></ol> <h4>7. Liability</h4> <ul><li>To the fullest extent permitted by law, we are not liable for any indirect, special, or consequential losses, including loss of profits, arising from the use of our products.</li><li>Our total liability for any claim relating to your purchase is limited to the amount paid for the product.</li><li>Customers are responsible for checking product ingredients for any known allergies before use.</li></ul> <h4>9. Privacy and Data Protection</h4> <ul><li>We collect and process your personal data in accordance with our Privacy Policy, which is available on our website.</li><li>Your personal information is used to process your order, deliver products, and provide customer support.</li></ul> <h4>11. Governing Law</h4> <ul><li>This agreement is governed by the law of Scotland. Each party irrevocably submits to the exclusive jurisdiction of the courts of Scotland and courts of appeal from them in respect of any proceedings arising out of or in connection with this agreement. Each party irrevocably waives any objection to the venue of any legal process on the basis that the process has been brought in an inconvenient forum.</li></ul> <h4>12. Contact Information</h4> <ul><li>For any questions or concerns regarding your order or these Terms, please contact us via email at help@wearethehelpful.com</li></ul> We are The Helpful A We are The Helpful kate@wearethehelpful.com none Y 1719394819 0 8 N N N 1733227771 1736859218 1733232616 1736859218 N 5 acct_1QNAlWKiNYt4A4TK S WE ARE THE HELPFUL RETAIL gentle-habits 4_0