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 8033879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:50:21+00:00 2026-06-05T01:50:21+00:00

I am not expert in sql and I need help with the following query.

  • 0

I am not expert in sql and I need help with the following query. It is poorly optmized and it takes too long time to execute.
Is it possible to replace IN() with JOIN() to speed up the query?
How to do it?

SELECT * 
FROM   shop_orders 
WHERE  id IN (SELECT orders_id 
              FROM   shop_orders_data 
              WHERE  closed = '1' /*AND backorder='0'*/) 
       AND id IN (SELECT orders_id 
                  FROM   shop_orders_products 
                  WHERE  products_id IN (SELECT id 
                                         FROM   shop_products 
                                         WHERE  artno = '120000' 
                                                 OR name LIKE '%120000%')) 
ORDER  BY created DESC 
  • 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-05T01:50:22+00:00Added an answer on June 5, 2026 at 1:50 am
    Select so.*
    from shop_orders as so
         join shop_orders_data as sod on sod.orders_id = so.id
         join (select orders_id 
               from   shop_orders_products as sop
                      join shop_products as sp on sp.id = sop.products_id
               where  sp.artno = '120000' 
                      OR sp.name like '%120000%') as sop on sop.orders_id = so.id
    where 
      sod.closed = '1'
    order by so.created desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not an expert with either System.Data nor SQL Server, but have a need
To anyone who can help. I am not an expert at T-SQL so I
To anyone who can help. I am not an expert at T-SQL so I
I'm not a SQL expert (by any means). I know I can do this
I am not expert in ASP so i would be appreciated for the help.
I am not that expert in SSIS. Can anybody help me out on my
I am trying to make SELECT statement for following situation and need help to
i have the following union query sql in my code (SELECT TableA.ID, TableB.Group, ''
I am trying to develop a T-SQL query which will do the following: ROUND(100
I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this

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.