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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:47:26+00:00 2026-05-26T16:47:26+00:00

I have 2 tables FinalList and RemoveTheseIDsList . They both have the same primary

  • 0

I have 2 tables FinalList and RemoveTheseIDsList. They both have the same primary key of ID. I want to remove all rows from FinalList that are in RemoveTheseIDsList. So, I wrote this first query:

Delete from FinalList
    Where FinalList.ID not in (Select ID from RemoveTheseIDsList)

In theory, that query should have deleted every single row from FinalList. Instead, it deleted 0. I eventually settled on this clunky workaround (which does work):

Update FinalList set DeleteMe='Y'
    from FinalList FLL
    left join RemoveTheseIDsList REM on FLL.ID=REM.ID
    where REM.ID is null
Delete from FinalList where DeleteMe='Y'

My question is: why did that first query not work? Is there a quick fix that’ll keep this query both functionable and small?

  • 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-26T16:47:26+00:00Added an answer on May 26, 2026 at 4:47 pm

    As you say : “I want to remove all records from FinalList that are in RemoveTheseIDsList”

    So it should be :

    Delete from FinalList
    Where FinalList.ID IN (Select ID from RemoveTheseIDsList)
    

    But your update is like a not in so maybe try this :

    Delete from FinalList
    Where FinalList.ID NOT IN (Select RemoveTheseIDsList.ID from RemoveTheseIDsList)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 tables, and want to get records from 1 table and to
I have some simple tables (multiple, all with class=parent) with multiple <tr> rows. The
i have tables driver, cars and trailers they are all in relationship. and main
hey all I have tables with millions of rows in them and some of
Some sites have tables which appends rows when you scroll the browser so that
In my database I have tables that define types for example Table: Publication Types
When I have tables in my database that have PK/FK relationships (int) and when
I have two tables that are joined together. A has many B Normally you
I have tables named: Posts_August_2011 Posts_September_2011 Posts_October_2011 Posts_November_2011 Posts_December_2011 Posts_January_2012 I want to create
I have tables with listings, categories and one that maps them to each other.

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.