Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compare And Display Multiple Column Data Based On Condition

def-enderOct 19 2015 — edited Oct 25 2015

Hi,

I have a requirement where I want to compare data from two tables and display only the columns if they is a mismatch using sql query.

Say userid, email and phone number of the same employee are stored in two tables. Now I want to compare the data of email and phone number from both the tables and display email and phone number only if they are different data.

employee table:

user_idemailphone
emp01emp01@xyz.com00200
emp02emp02@xyz.com

00300

emp03emp03@xyz.com00400

user_details table:


iduser_emailuser_phone
emp01emp@xyz.com00201
emp02(null)00300
emp03emp00@xyz.com00401


Please note that the two tables have completely different column names and the data can contain null value as well. What I want to achieve is compare the data of the same employee across the two tables and display the columns which have different value in user_details table; like:


user_iduser_emailphone
emp01emp@xyz.com00201
emp02(null)
emp03emp00@xyz.com00401


As the table column names are different, I cannot use a join and minus to find out the difference. I tried this with using CASE after the WHERE clause for multiple column comparison but OR or AND both would defy the condition of displaying all columns with different data for the same row.


How do I achieve this without creating a separate view or table as I do not have a write access? Any pointers would be helpful.


-Thanks.


This post has been answered by Etbin on Oct 25 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2015
Added on Oct 19 2015
9 comments
2,586 views