×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Two Tables

Two Tables

Two Tables

(OP)
I have two simple tables with 2 fields each. I want to compare these tables and just get the entry(ies) that exists in the second table and does not exist in the first table.

Is there a way to do that?

Regards,

MHendler

RE: Two Tables

What are you using to access the data?

If MS Access for example, you can use the "not in" as part of the query.

The example I have in a book SQL Fundamentals (ISBN 0-13-096016-0) gives the following:
*************************************
select a.number_2,
       a.word_2
from twos a
where (number_2 & a.word_2) not in (select (b.number_2 & b.word_2) from twos_modified b);
**************************************

twos = first table
twos_modified = second table

You can also do it using the UNION where you get the data from table1 and then table2 with a text column to show the source, e.g.
*********************************
select number_1,
       word_1,
       date_1,
       'data from first table' as source_of_the_data
from First_table
union
select number_2,
       word_2,
       date_2,
       'data from second table' as source_of_the_data
from second_table
order by number_1;
***********************************
Notes:
only unique records will be in the result and you will be able to see which records are from which table.

both table must have the same data types

Hope this helps.
Noddy

RE: Two Tables

Can you give a little more detail.  Do the two tables have the same types of fields?  Do you want both fields to be 'unmatched' or either one?  Any indexes on the fields in each table?

RE: Two Tables

THE OPERATOR "UNION" RETURNS ALL DISTINCT ROWS BY EITHER OF THE QUERIES IT APPLIES TO.

EXAMPLE:

SELECT ENAME, JOB
FROM   EMP_1
UNION  
SELECT ENAME, JOB
FROM   EMP_2
ORDER BY ENAME;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close