Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:09:05+00:00 2026-06-14T17:09:05+00:00

Here is the SQL query in question: select * from company1 left join company2

  • 0

Here is the SQL query in question:

select *  from company1 
left join company2 on company2.model 
    LIKE CONCAT(company1.model,'%') 
    where company1.manufacturer = company2.manufacturer

company1 contains 2000 rows while company2 contains 9000 rows.

The query takes around 25 seconds to complete.

I have company1.model and company2.model indexed.

Any idea how I can speed this up? Thanks!

+----+-------------+-----------+------+---------------+------+---------+------+------+--------------------------------+
| id | select_type | table     | type | possible_keys | key  | key_len | ref  | rows | Extra                          |
+----+-------------+-----------+------+---------------+------+---------+------+------+--------------------------------+
|  1 | SIMPLE      | company1  | ALL  | NULL          | NULL | NULL    | NULL | 2853 |                                |
|  1 | SIMPLE      | company2  | ALL  | NULL          | NULL | NULL    | NULL | 8986 | Using where; Using join buffer |
+----+-------------+-------+---+------+---------------+------+---------+------+------+--------------------------------+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:09:06+00:00Added an answer on June 14, 2026 at 5:09 pm

    This query is not conceptually identical to yours, but maybe you want something like this? I am quite sure it will give you the same result as yours:

    select
      *
    from
      company1 inner join company2
      on company1.manufacturer = company2.manufacturer
    where
      company2.model LIKE CONCAT(company1.model,'%')
    

    EDIT: i also removed your left join and put an inner join. If the join doesn’t succeed, company2.model is always null and NULL LIKE 'Something%' can never be true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL server 2008 Hello here is my query which returns the result SELECT *
Here is my SQL query: SELECT (CASE (elapsed_time_from_first_login IS NULL) WHEN true THEN 0
I started to take a look at the following question: https://stackoverflow.com/questions/8616458/sql-query-like-clarification Unfortunately it appeared
Here is a SQL query which fail if multiple values are returned by first-
I'm having an issue extracting a substring in SQL query results. Here's the situation:
This question already has an answer here: view sql that linq-to-sql produces 3 Answers
here is the sql codes SELECT roles.role_id, usertype_module.role_id, usertype_module.viewable, usertype_module.editable, usertype_module.createable, modules.modules_id, usertype_module.modules_id, modules.modules,
I am using this SQL query DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) select
This is sort of SQL newbie question, I think, but here goes. I have
Good day, my question is about optimizing sql query. The following query is slow:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.