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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:18+00:00 2026-05-26T15:09:18+00:00

I am working a problem from the Stanford DB class and have a question.

  • 0

I am working a problem from the Stanford DB class and have a question. I have 2 tables. The first table has 2 fields, so we have T1(ID1,ID2). The second table has some more columns.

If I do

select T1.ID1, T1.ID2
from T1, T2 as X, T2 as Y, T2 as Z
where <condition>
except
select T1.ID2, T1.ID1
from T1, T2 as X, T2 as Y, T2 as Z
where <different condition>;

then I get 2 tuples

A1 | B1
A2 | B2

as a result. This is just what I was expecting.

The issue is how do I delete the rows from T1 using these tuples?

I tried

delete
from T1
where ID1=(<select from above using only the first variable in the select>)
  and ID2=(<select from above using only the second variable in the select>);

This didn’t work and I don’t see a way to do it.
Any clues?
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-26T15:09:19+00:00Added an answer on May 26, 2026 at 3:09 pm

    Not sure if this is possible in SQLite, but you could give it a try:

    DELETE FROM T1
    WHERE EXISTS (
      SELECT *
      FROM (
        select T1.ID1, T1.ID2
        from T1, T2 as X, T2 as Y, T2 as Z
        where <condition>
        except
        select T1.ID2, T1.ID1
        from T1, T2 as X, T2 as Y, T2 as Z
        where <different condition>
      ) s
      WHERE s.ID1 = T1.ID1
        AND s.ID2 = T1.ID2
    )
    

    That might be sub-optimal and maybe you could instead split your EXCEPT query like this:

    DELETE FROM T1
    WHERE EXISTS (
      /* slightly modified left part of the EXCEPT query */
      select T1.ID1, T1.ID2
      from T1 AS T1_, T2 as X, T2 as Y, T2 as Z
      where <condition>
        AND T1_.ID1 = T1.ID1
        AND T1_.ID2 = T1.ID2
    )
    AND NOT EXISTS (
      /* slightly modified right part of the EXCEPT query */
      select T1.ID2, T1.ID1
      from T1 AS T1_, T2 as X, T2 as Y, T2 as Z
      where <different condition>
        AND T1_.ID2 = T1.ID1
        AND T1_.ID1 = T1.ID2
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do have a problem working with my application. I am using AsyncTask class
I have a problem working with some worksheets within a workbook from a 3rd
I have a strange problem working with HTML,CSS in different browsers: Firefox 3.6 and
I am working on a problem and got stuck at a wall I have
I have been working on this problem for 2 days now and it's an
I have been working on this problem for a while now. I am trying
I have a weird encoding problem from my PyQt app to my mysql database.
To describe my dilemma, let me first start with an example problem (stolen from
I'm still working on that bitmap I/O problem from a week ago. I got
So the problem changed from what it was, i'll leave the original question below

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.