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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:32:19+00:00 2026-05-17T15:32:19+00:00

I have two tables (A and B). I want to delete all the rows

  • 0

I have two tables (A and B).

I want to delete all the rows in Table B where B.1 isn’t in Table A.2.

So I wrote this formula in sqlite:

DELETE FROM B 
WHERE 1 
IN 
 (SELECT * 
  FROM B 
  LEFT JOIN A 
  ON A.1=B.2 
  WHERE A.1 
  IS NULL)

But this returns this error:

only a single result allowed for a SELECT that is part of an expression

Could anyone give me a hand?

Thanks.

  • 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-17T15:32:19+00:00Added an answer on May 17, 2026 at 3:32 pm

    The issue for your example query is that an IN clause can not be used in conjunction with SELECT * when the SELECT * returns more than one column. You need to specify the column…

    NOT IN

    DELETE FROM B
     WHERE B.2 NOT IN (SELECT A.1
                         FROM A)
    

    NOT EXISTS

    DELETE FROM B
     WHERE NOT EXISTS (SELECT NULL
                         FROM A
                        WHERE A.1 = B.2)
    

    SQLite doesn’t support JOINs in DELETE statements, but you could also use:

    DELETE FROM B
     WHERE B.2 IN (SELECT B.2
                     FROM B
                LEFT JOIN A ON A.1 = B.2
                    WHERE A.1 IS NULL)
    

    Conclusion:

    I don’t have any performance statistics for SQLite, but the NOT EXISTS would be my choice because it returns true on the first time it’s satisfied–very good for dealing with duplicates.

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

Sidebar

Related Questions

My problem is I want to delete records from two tables, deleting the records
Say I have two tables I want to join. Categories: id name ---------- 1
Hi I want to have two tables each have an INT id column which
I have two tables containing Tasks and Notes, and want to retrieve a list
I have two tables, movies and categories , and I want to get an
I have a dataset that has two tables in it. I want to do
I have two tables Table A: ID 1 2 3 4 Table B: ID
I have created two tables ORDERS and ORDERITEMS with the following constraint: alter table
I have a very large database (~100Gb) primarily consisting of two tables I want
I have two tables: orders and orders_items. Both sharing the field orderID. I want

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.