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

Query time 0.00206

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
30 en <p>Lauren has created powerful and endorphin boosting sessions to support and refine your holistic goals. Using the Pilates principles; Breath, Concentration, Control, Precision, Centre and Flow classes are catered to all levels regardless of your age, gender, health status or fitness level. Let her inspire you! With over 150+ classes to chose from, weekly schedules and challenges, Elevate by Lauren will transform and refine your movement. Building a stronger body and mind for your future self.</p><p> Including a dedicated 40 week guided Pregnancy Pilates series approved by physios filmed throughout her own pregnancy,  and a post natal Restore your Core programme created to help mothers heal and restore post birth. Suitable for both C-section and vaginal births.</p> <h2></h2> <p>Terms & Conditions</p> <p>The voucher is valid for 12 months from date of purchase. The discount code must not be shared or transferred to any other individual other than the intended person it was gifted to. If this has been discovered to have happened the account will be deleted and access to Elevate by Lauren will be denied.</p> <p>By taking part in these sessions you are agreeing to these Terms and Conditions. Members hereby confirm that they have no health problems (including without limitation cardiac irregularities; spinal, bone, joint, tendon or ligament injuries; spells of dizziness; asthma (or other breathing difficulty); diabetes, epilepsy or any allergy) which may affect their participation in any classes on this platform. They confirm they have been accessed by a GP, and have been given clearance to exercise by a medical professional.</p> <p>I assume all risk of participating in class and agree that Elevate by Lauren Anderson will not be liable for any injury, illness, or similar difficulty that I may suffer arising out of or connected with my participation in class.</p> <p><b>By using Sudor you agree to these terms.</b></p> <p>These are Sudor’s terms of use, and they apply to all users of the Sudor platform. “We,” “our” or “us” refers to Global Fitness Holdings Ltd. and our subsidiaries. “Sudor” refers to this platform and the services offered by us.</p> <p>By using Sudor you agree to these terms and to the other policies we include on the Ts&Cs on our website which are subject to change from time to time with notice. Please read them carefully and let us know if you have any questions. These terms are also subject to the terms and rules of the App store from whose site you downloaded the Sudor app. For information about the App store terms see the relevant App store site and for information on our data practices, please see our Privacy Policy. We can collect, process and use personal information in accordance with those policies.</p> <p>As a member, you must be at least 18 years old or have your parent’s permission to subscribe to Elevate by Laurens videos. As a member you are responsible for anything that occurs when anyone is signed in to your account, as well as the security of the account.</p> <p><b>Sudor</b></p> <p>All intellectual property rights in the App belongs to Sudor and its licensors. The use of the App by a PTP or Fan will not entitle either to any ownership (including copying or editing or harvesting of any information any similar action) of the app.</p> <p>The Fan/PTP must not: (i) test, scan or circumvent the security of Sudor; (ii) use the account of another Fan/PTP or impersonate another Fan/PTP when using Sudor; or (iii) give any false details when creating and using an account (i.e. you must provide your real name and contact information).</p> <p>We will set the price of subscriptions payable by Fans. These amounts may change from time to time and may vary from country to country.</p> <p>Sudor will contract with Apple, Google and/or any other payment gateway so as to ensure that any subscription payments made by Fans and collected by Apple (App Store), Google (Play Store) or any other app provider and received by Sudor are then paid to PTPs after deducting Sudor’s fees, any third party fees, and any necessary taxes we are required by law to deduct. Sudor shall not be responsible for the security of subscriptions payments whilst under our possession or control.</p> <p><b>Fees and Taxes</b></p> <p>Members accept that they will have to pay a subscription fee to access Sudor (whether it is a quarterly or annual subscription). This subscription payment will renew automatically every month unless you cancel your subscription with Sudor</p> <p><b>Account deletion</b></p> <p>You can delete your account by contacting us via our website and providing us with 30 days’ notice of your wish to delete your account. We can disable your account at our discretion.</p> <p>Sudor reserves the right to terminate accounts in the case of a PTP or Fan breaching Community Guidelines or for any other reason in Sudor’s sole discretion.</p> <p>These terms remain in effect even if you no longer have an account. After account deletion, where you are a PTP, we will retain your content and keep it uploaded on Sudor unless you ask us to take it down. We will aim to remove your content from Sudor within 30 days after you ask us to. However, we shall keep exclusive possession of the content and you cannot use that content anywhere else, except where the content is filmed by you using your own equipment, and is uploaded to the Sudor server by you, then you may retain possession of the content and can upload the content elsewhere.</p> <p>Members may not use videos uploaded by Elevate by Lauren in any way not authorized by the Elevate by Lauren </p> <p><b>Warranty disclaimer</b></p> <p>We do our best to make sure Sudor works as expected, but stuff happens.</p> <p>Sudor is provided “as is” and “as available” and without warranty of any kind. Any warranty of merchantability, satisfactory quality, fitness for a particular purpose, non-infringement, and any other warranty is excluded to the greatest extent permitted by law.</p> <p>The disclaimers of warranty under this clause also apply to our subsidiaries, affiliates and third party service providers.</p> <p><b>Dispute Resolution</b></p> <p>We encourage you to contact us if you have an issue. If a dispute does arise out of these terms or related to your use of Sudor, and it cannot be resolved after you talk with us, then it is agreed that these terms are governed by English law and Fans/PTPs can only bring claims in the courts of England.</p> <p></p> Elevate by Lauren A Elevate by Lauren laurenvassanderson@gmail.com +447950900425 none Y 1737449776 0 a:4:{s:14:"company_fields";a:6:{i:37;s:6:"Lauren";i:38;s:8:"Anderson";i:53;s:31:"We are an online pilates studio";i:54;s:37:"Pre and post natal Pilates programmes";i:55;s:79:"We support all bodies throughout our range of carefully curated movement plans.";i:56;s:24:"The body, mind and soul!";}s:15:"admin_firstname";s:6:"Lauren";s:14:"admin_lastname";s:8:"Anderson";s:6:"fields";a:0:{}} 1 10 N N N 0 0 0 0 N 0 acct_1NkWmHCV52I8Gqy2 S Launch - 20% elevate-by-lauren 30_0