compare value from two tables

hi how can i compare value from this two tables

i what to see emp1 accnumber value which is difiirent from accnumber emp2
 
something like this
select * from emp1
minus
selet * from emp2
chalie001Asked:
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.

MlandaTCommented:
select accnumber from emp1
where accnumber not in (select accnumber from emp2)

Open in new window

0
slightwv (䄆 Netminder) Commented:
What are the primary keys of the tables?

You should be able to join the two tables on the primary keys and compare the two columns.
0
MlandaTCommented:
slightvw.. you highlight a key distinction... its not clear whether the comparison is to find things in emp1 not emp2 OR where the same "emp" entity has 2 different values in the two tables... something like...
select emp1.emp_id, emp1.accnumber, emp2.emp_id, emp2.accnumber 
from emp1
     inner join emp2 on emp1.emp_id = emp2.emp_id

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

chalie001Author Commented:
i what to display value like this
table emp1
mpno,empname,telno,address,hire_date,accnumber,acc_desc
0992,twww,09222333,no2222,2010/09/09,ac0993,saving
 
 
table emp2
empno,empname,telno,address,hire_date,accnumber,acc_desc
0992,twww,09222333,no2222,2010/09/09,acc09222,saving
 
value i what to see
empno,empname,telno,address,hire_date,accnumber,acc_desc,diffirent_details
0992,twww,09222333,no2222,2010/09/09,ac0993,saving,  emp1 accn0 ac0993,emp2 accno acc09222
0
slightwv (䄆 Netminder) Commented:
Try the join example posted above.

What that won't show you is missing records from either table.
0
slightwv (䄆 Netminder) Commented:
0
chalie001Author Commented:
this is from same database and there is extra column diffirent_details after i return value from query to display the diffirent value
0
chalie001Author Commented:
and am comparing one column
0
slightwv (䄆 Netminder) Commented:
I do not understand that last post.

Was it an attempt to explain how this question is different from your previous question?

If so, I don't see the difference.  Two tables are two tables.  Same database or different doesn't matter.  It is still a join between them and comparing the columns.

Everything in the previous question concerning nulls still counts here.

I see this as the same question.

Please explain how it is different.
0
slightwv (䄆 Netminder) Commented:
>>and am comparing one column

Comparing one column or 1000 columns.  Do it the same way.
0
chalie001Author Commented:
i what something like this but with extra column diifirent_values

diffirent_details
emp1 accn0 ac0993,emp2 accno acc09222


select * from emp1
where emp1.accnumber not in (select emp2.accnumber from emp2);

Open in new window

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
MlandaTCommented:
Please give more test data (at least a few rows... 10 maybe), realistic data and give a proper example of the output you want. I don't think we are on the same page here. We have to setup a fiddle otherwise you're not going to get an answer here. What you just posted above cannot be achieved without a JOIN. So we keep going round in circles on the issue
0
MlandaTCommented:
In fact.. looking at your example output more closely... I cannot see what is wrong with the previous fiddle I gave you. Did you try the two variants of the query which I gave you?

Why do you want to have a different_values column in that format (on my versions, I just set it to 1 or 0 depending on whether there is a difference)? The way you want, just results in complex queries... which you also didnt want to have for all your columns.
0
chalie001Author Commented:
correct
0
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
Databases

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.