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

Query time 0.00067

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
16 en <p>These terms and conditions outline the rules and regulations for the purchase of The Food Doula products.</p> <p>By purchasing our products, we assume you accept these terms and conditions. Do not continue to use The Food Doula if you do not agree to take all of the terms and conditions stated on this page. These terms and conditions shall be governed by and interpreted in accordance with the laws of England.</p> <p>The Food Doula operates under the THE FOOD DOULA. The registered business address is Holly Folly, Dummer Down Farm, Basingstoke, Hampshire, RG25 2AR.</p> <p>We have the right to revise and amend these terms and conditions from time to time to reflect changes in market conditions affecting our business, changes in technology, changes in payment methods, changes in delivery operations, relevant laws and regulatory requirements and changes in our system's capabilities. All such changes will be published on the website. If you use our website or place any order with us after the changes have been published, you are agreeing to be bound by those changes in respect of that order.</p> <p>When we refer to ‘you’ and ‘your’ we mean the user of the website and the purchaser of the goods. We will confirm acceptance of your order by e-mail to the address given and the sending of this e-mail, binds the contract between us.</p> <p>ALLERGENS</p> <p>Our products are made in a kitchen which stores and handles all allergens. Allergens will be clearly labelled on the product label. It is the customer’s responsibility to check the ingredient list to check for any allergens they wish to avoid. While we take the best care to avoid cross contamination when preparing a dish without allergens, note we cannot guarantee that the dishes are free from allergens as they are prepared in an environment which handles them therefore we are unable to cater to any customers with severe allergies which cause anaphylactic shock.</p> <p>DELIVERY</p> <p>When you order any product from The Food Doula we need the following details. Your address, including the postcode of the billing address associated with the payment card. Your mobile telephone number. Your email address, so we can supply you with important information such as your order confirmation and changes to the The Food Doula delivery service. If gifting or shipping to an address different to that your card is registered at, you must provide the correct shipping address and postcode to ensure delivery to the correct address.</p> <p>If you are gifting it’s important we have the phone number of the recipient so they can manage receiving the delivery by leaving safe place instructions via the courier notifications for example. The goods will be delivered to the shipping address you provide at checkout, this address is confirmed on your order confirmation and must be checked for errors. Once an order is shipped this address cannot change. We are not liable for any delays or missed deliveries if the delivery address provided is erroneous, any replacements or refunds are entirely at the discretion of the business. If you realise after the product has been shipped by our courier partners you must not change the address, you must contact thefooddoula@gmail.com to manage any address mistakes.</p> <p>We are not responsible for delivery delays outside of our control. If delivery is delayed we will contact you as soon as possible to let you know and we will take steps to minimise the effect of the delay. If your order cannot be delivered on the expected delivery date, we may contact you to arrange a suitable alternative for the next available delivery date, or you may contact us in writing to request a refund.</p> <p>If you choose to save your credit card details during the order process, these details will be held by Stripe, a third party payment provider. No credit card details are stored by The Food Doula.</p> <p>PRODUCTS & PRICING</p> <p>The price of goods charged shall be as quoted on the web site at the time you confirm your order with us. Excluding any inadvertent technical error on pricing, we will honour any prices as published at the time of placing your order. The Food Doula has the sole right to change any planned menus at our discretion at any point. The meals are designed to use fresh seasonal ingredients and occasionally these might not be available as planned. The Food Doula will review pricing</p> <p>DISCOUNTS</p> <p>If the discount code or promotion you intended to use has not been successfully applied and the order completed within the specified time frame we are not obliged to re-issue a voucher code or apply the discount retrospectively. Most codes will not be valid for use in conjunction with other offers. You may be offered a discount or promo code via a pop up on the website as a first time customer, via email newsletter, partners of The Food Doula or via the flyer you receive in your order. Please check your voucher expiry dates as they may have a time limit and we do want you to be able to use them as valued customers.</p> <p>CANCELLATION OF AN ORDER</p> <p>As an online retailer we are governed by the UK Distance Selling Regulations. However, as we are selling perishable goods, the regulations relating to the return of unwanted goods do not directly apply to us. For more information, please go to<a href="http://www.dti.gov.uk/"> www.dti.gov.uk</a>. Orders can be cancelled any time up until 7 days before planned delivery date. Rejecting an unwanted order will not result in a refund. As our goods are perishable they will be destroyed by the courier upon rejection and therefore not warrant a refund.</p> <p>REFUNDS</p> <p>If you are unsatisfied with any of the items in your order or any part of the delivery service from The Food Doula please contact us by emailing us at thefooddoula@gmail.com. As we sell perishable goods, we ask that you – the customer – inspect the your order once you have opened the box. If you are unhappy with the goods, please contact us immediately on thefooddoula@gmail.com. At our discretion, we may exchange or refund any item you feel does not our quality standards, or any item that has been damaged in transit.</p> <p>VOUCHERS</p> <p>If you have purchased a gift voucher, this is valid to be redeemed 1 year from the date of purchase. If the amount on the voucher does not reach the total cost of the products you are ordering, the voucher amount will be subtracted from the total and you will pay the remainder using your card details at the checkout after entering the code. If there is money left on the voucher, this can be used within the 1 year period, since original purchase.</p> <p></p> The Food Doula A The Food Doula thefooddoula@gmail.com 07814683756 none Y 1728470552 24 0 a:4:{s:14:"company_fields";a:6:{i:37;s:4:"Kate";i:38;s:7:"Longden";i:53;s:1:"-";i:54;s:1:"-";i:55;s:1:"-";i:56;s:1:"-";}s:15:"admin_firstname";s:4:"Kate";s:14:"admin_lastname";s:7:"Longden";s:6:"fields";a:0:{}} 1 9 N N N 0 0 0 0 N 0 acct_1DYz0EG1gMh3cMR4 S Launch - 15% the-food-doula 16_0