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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:30:21+00:00 2026-06-04T16:30:21+00:00

lets say I have two tables: TableA ID, Time, Size 0 5:00 600 1

  • 0

lets say I have two tables:

TableA
ID,    Time,   Size

0      5:00    600
1      8:00    800
2      7:00    100
3      1:50    140
4      2:40    300 
12     3:40    300

TableB
ID,    Time,   Size

8      5:00    600
1      8:00    800
2      8:00    900
3      1:50    140
5      2:40    300 
12     3:40    300 

Now I would like to compare these two Tables: give all rows from Table A and B where the IDs are same (or lets say where the IDs are existing in both of the Tables) but lower then 12 – so that would kick out table A ID 0, 4, 12 and from table B ID 8, 5, 12

After that I would have only 3 rows left. Now I would like to kick out all rows where there is one or more difference between the whole TableA row ID == TableB row ID

At the end there would be (if I see that correct) as output:

ID,    Time,   Size
1      8:00    800
3      1:50    140

For this solution I need for sure intersect and maybe minus. At first I tought this SQL statement would do what I want:

select * from TableA where ID < 12 intersect select * from TableB where ID < 12 
minus 
select * from TableB where ID < 12;

But this is not working that well. Ist because of the intersect, Im using intersect for the whole row, I should use intersect for only the IDs and IF I have the intersect of the IDs (that would be 1,2,3) then I have to use ID TableA with ID 1,2,3 minus TableB with ID 1,2,3. But how? Or do I miss something? Any ideas? Thank you

  • 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-04T16:30:22+00:00Added an answer on June 4, 2026 at 4:30 pm
    select id from TableA where ID < 12 and id in (Select id from TableB)
    union 
    select id from TableB where ID < 12   and id in (Select id from TableA)
    

    or

    SELECT id, 
           time, 
           size 
    FROM   (SELECT * 
            FROM   tablea 
            WHERE  id < 12 
            UNION ALL
            SELECT * 
            FROM   tableb 
            WHERE  id < 12) a 
    GROUP  BY id, 
              time, 
              size 
    HAVING Count(*) = 2 
    

    or

    SELECT * 
    FROM   tablea A 
    WHERE  EXISTS (SELECT 1 
                   FROM   tableb b 
                   WHERE  b.id = a.id 
                          AND b.time = a.time 
                          AND b.size = a.size) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have two tables tblA ( tableAID INT IDENTITY(1,1), foo VARCHAR(100)) tblB
Lets say I have two tables - Cat and Cat owner that are linked
Lets say I have data in two tables. In one I have Order ID
Lets say I have two tables like this: person: id, first_name, last_name, phone_id phone:
Lets say i have two tables EMPLOYEE and INCHARGE_ROOM , EMPLOYEE.INCHARGE_ROOMS has | delimted
lets say, i have two tables, one for object records and one for activity
Lets say I have two tables - child and parent with many-to-one relation. What
Lets say I have these two tables: CREATE TABLE nodes ( id INTEGER PRIMARY
Lets say I have two tables in Postgres: Name: table_rad Column Type id integer
Lets say I have two tables, Tool and IOPoint, both with GUID as the

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.