SELECT 
  company_descriptions.*, 
  companies.*, 
  vendor_plan_descriptions.plan, 
  seo_names.name as seo_name, 
  seo_names.path as seo_path, 
  vendor_ga_tracking_code, 
  vendor_fb_tracking_code, 
  AVG(discussion_rating.rating_value) AS average_rating, 
  CONCAT(
    companies.company_id, 
    '_', 
    IF (
      discussion_rating.thread_id, discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids 
FROM 
  companies AS companies 
  LEFT JOIN company_descriptions AS company_descriptions ON company_descriptions.company_id = companies.company_id 
  AND company_descriptions.lang_code = 'en' 
  LEFT JOIN vendor_plan_descriptions ON companies.plan_id = vendor_plan_descriptions.plan_id 
  AND vendor_plan_descriptions.lang_code = 'en' 
  LEFT JOIN seo_names ON seo_names.object_id = 5252 
  AND seo_names.type = 'm' 
  AND seo_names.dispatch = '' 
  AND seo_names.lang_code = 'en' 
  LEFT JOIN discussion as discussionA ON discussionA.object_id = companies.company_id 
  AND discussionA.object_type = 'M' 
  LEFT JOIN discussion_posts ON discussion_posts.thread_id = discussionA.thread_id 
  AND discussion_posts.status = 'A' 
  LEFT JOIN discussion_rating ON discussionA.thread_id = discussion_rating.thread_id 
  AND discussion_rating.post_id = discussion_posts.post_id 
WHERE 
  companies.company_id = 5252

Query time 0.00265

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.81"
    },
    "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": "14K"
          },
          "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",
            "plan_id",
            "stripe_connect_account_id",
            "identifier_facebook_pixel",
            "featured_products",
            "sd_ga_tracking_code",
            "paypal_commerce_platform_account_id",
            "tagline",
            "url_facebook",
            "url_instagram",
            "url_twitter",
            "url_pinterest",
            "announcement",
            "shippo_api_token",
            "shippo_carrier",
            "shippo_service_type",
            "vendor_ga_tracking_code",
            "vendor_fb_tracking_code",
            "custom_domain",
            "custom_domain_status",
            "taxjar_key",
            "taxjar_export_statuses",
            "taxjar_export_csv_data",
            "ag_hide_city",
            "updated_timestamp",
            "suspend_date",
            "grace_period_start",
            "last_time_suspended",
            "last_debt_notification_time",
            "tax_number",
            "stripe_connect_account_type",
            "registered_from_storefront_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",
            "subdomain_colors",
            "i18n_company",
            "i18n_address",
            "i18n_city"
          ]
        }
      },
      {
        "table": {
          "table_name": "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": "1K"
          },
          "used_columns": [
            "plan_id",
            "lang_code",
            "plan"
          ]
        }
      },
      {
        "table": {
          "table_name": "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.86",
            "eval_cost": "0.10",
            "prefix_cost": "0.96",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "name",
            "object_id",
            "type",
            "dispatch",
            "path",
            "lang_code"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussionA",
          "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",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.71",
            "eval_cost": "0.10",
            "prefix_cost": "1.77",
            "data_read_per_join": "24"
          },
          "used_columns": [
            "thread_id",
            "object_id",
            "object_type"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussion_posts",
          "access_type": "ref",
          "possible_keys": [
            "thread_id",
            "thread_id_2"
          ],
          "key": "thread_id_2",
          "used_key_parts": [
            "thread_id",
            "status"
          ],
          "key_length": "6",
          "ref": [
            "goimagine.discussionA.thread_id",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.18",
            "prefix_cost": "2.19",
            "data_read_per_join": "787"
          },
          "used_columns": [
            "post_id",
            "thread_id",
            "status"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussion_rating",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "thread_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "post_id"
          ],
          "key_length": "3",
          "ref": [
            "goimagine.discussion_posts.post_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.44",
            "eval_cost": "0.18",
            "prefix_cost": "2.81",
            "data_read_per_join": "28"
          },
          "used_columns": [
            "rating_value",
            "post_id",
            "thread_id"
          ],
          "attached_condition": "<if>(is_not_null_compl(discussion_rating), (`goimagine`.`discussion_rating`.`thread_id` = `goimagine`.`discussionA`.`thread_id`), true)"
        }
      }
    ]
  }
}

Result

company_id lang_code company_description terms subdomain_colors 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 plan_id stripe_connect_account_id identifier_facebook_pixel featured_products sd_ga_tracking_code paypal_commerce_platform_account_id tagline url_facebook url_instagram url_twitter url_pinterest announcement shippo_api_token shippo_carrier shippo_service_type vendor_ga_tracking_code vendor_fb_tracking_code custom_domain custom_domain_status taxjar_key taxjar_export_statuses taxjar_export_csv_data ag_hide_city updated_timestamp suspend_date grace_period_start last_time_suspended last_debt_notification_time tax_number stripe_connect_account_type registered_from_storefront_id plan seo_name seo_path average_rating company_thread_ids
5252 en <p>Hello!</p> <p>Welcome to design bcb. I'm Beverly Bochenek, owner and maker. I design some of my items and others are created from designs of talented knit and crochet members of the craft community. Either way, you will receive well made handcrafted items that will make great gifts for those you care about.&nbsp;</p> <p>Knit and crochet are spiritual gifts from God and the joy I get comes from the journey. The products you get are the destination. Those things work together to get you something made with love, filled with love and given with love. The whole world gets just a little bit better.</p> <p>Processing times can be up to three weeks during the peak times of the year. Communication is key and I will be in touch with you during the entire process from the time you place your order to the time it is delivered. Please feel free to contact me with custom requests. If you need something quickly, watch for the "Ready to Ship" on listings that can be sent out the next business day.</p> <p><strong>Processing Time</strong>: Processing times are 3-4 weeks during regular times and 4-5 during the peak times (Oct - Dec.) I will notify you of the estimated date your item will ship. I ship via USPS with tracking.</p> <p><strong>Returns, Exchanges, Cancellations</strong>: Contact me before returning an item. Returns are accepted within 5 days of receipt. Orders may be cancelled within 24 hours after purchase.</p> <p><strong>The following items cannot be returned or exchanged:</strong></p> <p>Custom orders, digital downloads, intimate items, clearance items</p> <p>Buyers are responsible for all return costs and for returning item in original condition. If item is not returned in original condition, buyer is responsible for loss of value.</p> <h6>What if I Don't Receive My Order?</h6> <p>We will open an investigation with the USPS. No refunds will be made until that investigation is completed. The tracking number allows both the buyer and seller to see where the package is in the delivery system and will assist in finding the package.<br><br>We take claims of non-receipt or missing items very seriously. Upon notification that items are missing or never received, we will open a case with the USPS and ask for an official postal inspection. This will include filing a form with all information, including the information of the buyer and seller. The postal service may interview the buyer and ask for a signed affidavit. Refunds are given after the inspection concludes AND if the inspection finds fault with the delivery system.</p> <h6>How Do I Return an Item?</h6> <p>First, contact me to let me know you wish to return. That provides protection for both buyer and seller. DO NOT RETURN AN ITEM WITHOUT CONTACTING THE SHOP FIRST.<br><br>Second, your shipping label must have tracking information, package weight and you must have confirmation of acceptance from the USPS or whatever carrier you use.<br><br>Lastly, keep the receipt and confirmation available until the transaction has been closed.</p> <h6>Stolen</h6> <p>Please note, it is the buyer's responsibility to have a secure location for packages to be delivered. Packages left on porches or other unsecured, unlocked places, are subject to theft. We are not responsible for stolen or taken items.<br>You are sent a photo of all items included in your order to review. You are also sent a phot of your packaged order, ready to ship. If an item is stolen this may be able to help USPS track it down.<br>As with lost or undelivered items, we will assist you in filing reports with the local USPS and local police authorities.<br>If buyer provides a valid police report, we will redo the order for half price created as a custom order.</p> <h6>Why Is There Tax Added on My Order</h6> <p>Some states require taxes on online purchases. designbcb has any control over this tax. It is added to your order per state law.</p> <h6>Missing Item</h6> <p>Customers are sent a photo of all items included in their package and a photo of the packaged order. Items are presented and scanned at USPS. If an item is missing do the following:<br>Take a photo of what was in your package<br>Save all packaging - place everything back in the package<br>Take photos of items and the packaged ordered along with the list of what was in the package to the USPS.<br>Have the package weighed<br>Ask them to compare the weight of the package now to the weight of the package when they received it.<br>Forward that information, including a copy of USPS receipt to me via Etsy messaging.<br>If applicable, we will follow the procedures for a stolen package.</p> <p><br></p> <p><br></p> <p><br></p> {"tmenu_style":"V","default_colors":"N","link_color":"#007d89","label_color":"#00a0af","icon_color":"#00a0af","main_btn_color":"#6dd1d6","branded_text_color":"#00a0af","vbp_1_url":"","vbp_2_url":"","vbp_3_url":"","vba_1_url":"","vba_2_url":"","vba_3_url":""} designbcb 8059 GRAND AVE, APT 1N River Grove A designbcb 8059 GRAND AVE, APT 1N River Grove IL US 60171 beverly@beverlybochenek.com +17735178247 none Y 1643842538 0 3 acct_1IxZBbCWa9mU32EI 220900,186243,225709 It's Cool to be Warm https://www.facebook.com/bcbochenek https://www.instagram.com/beverlybochenek_designbcb/ https://twitter.com/designbcb https://www.pinterest.com/designbcb/ <p>Welcome to designbcb - where handcrafted knit and crochet accessories make it cool to be warm! Here you will find affordable, functional and fashionable items to gift or to keep. Each item is handmade using fiber, needles and hooks. I use quality fiber but keep it affordable so everyone can find something.&nbsp;</p> <p>I also sell patterns so you can make it yourself - then you can choose how much you want to spend on fiber, what colors you wish and how long it takes to before you can use it.&nbsp;</p> <p>Join me on social media for updates and subscriber discounts.</p> oauth.UxZOXv8ROCh-Lk3Gwi2oisColuwHKIyB0u2fTuo0.07Pieys6aHvk0-3vZodDlTv19_5Of6l3lN9p1juRF8o UA-6995654-2 773881230287242 A N 0 0 0 0 0 S Professional Plan designbcb 5252_0