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

  • SEARCH
  • Home
  • 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 7084205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:16:21+00:00 2026-05-28T07:16:21+00:00

I wrote this query : SELECT * FROM etape_prospection INNER JOIN type_prospection ON etape_prospection.type_prosp_id

  • 0

I wrote this query :

SELECT * 
FROM etape_prospection INNER JOIN type_prospection 
ON etape_prospection.type_prosp_id = type_prospection.type_prosp_id 
WHERE etape_prospection.prosp_id IN (select transfert.prosp_id 
                                     from transfert 
                                     where transfert.user_code ='3' 
                                     AND transfert.date_transfert='2012-01-20');

My boss doesn’t like this query because of the IN keyword which makes a full table scan , so how to rewrite it without the IN keyword ?

  • 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-05-28T07:16:22+00:00Added an answer on May 28, 2026 at 7:16 am

    You can use EXISTS instead of IN this is usually cheaper than IN and sometimes also cheaper than the INNER JOIN suggested in other answers:

    SELECT * 
    FROM etape_prospection INNER JOIN type_prospection 
    ON etape_prospection.type_prosp_id = type_prospection.type_prosp_id 
    WHERE EXISTS (select 1
                   FROM transfert 
                   WHERE transfert.prosp_id = etape_prospection.prosp_id
                   AND transfert.user_code ='3' 
                   AND transfert.date_transfert='2012-01-20');
    

    Also (reminded by the comment by danihp on one of the other answers): using INNER JOIN can have the unwanted/unintended side effect of duplicating rows in the resultset if there are multiple rows in transfert that satisfy these conditions.

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

Sidebar

Related Questions

I wrote this sql query to search in a table: SELECT * FROM TableName
I wrote this query: SELECT * INTO #nima FROM Region r Every time I
I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order
I want to extract the parameters names from a query like this: select *
I didn't want to keep repeating the same select query, so I wrote this
For my database I create a new query and wrote select * from dbname
Query: select `r`.`id` as `id` from `tbl_rls` as `r` left join `tblc_comment_manager` as `cm`
$threadID=$_GET['threadID']; $result=mysql_query( SELECT * FROM threads AS Threads INNER JOIN users AS Users ON
In access I wrote this query: Select I.sysid, I.MemberNumber, I.Date, I.Distributer, F.MemberNumber as FMember,
I have this query: SELECT diamond_id, carat, clarity, color, cut, CASE clarity WHEN FL

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.