How do I compare two fields to list all records that do not match?

I'm trying to compare field1 in table1 which has 4600 records with field2 in table2 which has 9500 records to list all records in table1 that are not in table2.
shwelopoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

akalyan911Technical ConsultantCommented:
Hey.. you have to import the data first and then only can compare. without importing the data, you can't compare.
0
shwelopoAuthor Commented:
this is my query, it doesn't seem to work right.

select distinct SUBSTRING(table1.field1, 1, 6) from table1
where
field1

not in (select SUBSTRING(table2.field2, 1, 6) from table2)
0
Sean FitzpatrickSr Lab Systems EngineerCommented:
there's a command to compare data from two tables, but you will have to import all the data into a single spreadsheet first as akalyan911 stated.

Here's some examples of what you can do with tables.

http://office.microsoft.com/en-us/excel-help/use-excel-to-compare-two-lists-of-data-HA001103915.aspx
0
awking00Commented:
What dbms are you using? With the use of the substring function, perhaps it's sql server. If so you can use the except set operator -
select substring(field1, 1, 6) from table1
except
select substring(field2, 1, 6) from table2

In ms access, there is a query wizard to find unmatched records you can use.

In MySQL, you can use something like the following:
select substring(field1, 1, 6) from table1 as t1
where not exists
(select 1 from table2 as t2
 where substring(t1.field1,1,6) = substring(t2.field2,1,6))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.