By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Any approach to write query for finding data inconsistencies from multiple tables

P: 4

I have three tables with columns as:

Id(pk) name telephoneNum userid
----- -------- ---------------------- ---------

Id(pk) name telephoneNum userid
----- -------- ---------------------- ---------

telId(pk) telephoneNum personId
------ ---------------------- -------------

Data is populated through some application sync logic. Telephone <---> Person_sys2 <---> Person_sys1
Also these tables does not have foreign key relationship.

Now I need to write a query/ies ( single would be better) which would give me inconsistent rows of all there table for the following column mismatch (name,userid and telephoneNum).
If my data is consistent I should get zero rows otherwise rows that are mismatching for the below mentioned column values as per mapping.

Column Mapping (Arrow signifies sync direction) is as below:
------------------------------------------- ------>
Person_sys1.userid ------> Person_sys1.userid
Person_sys1.telephoneNum <------ Person_sys1. telephoneNum <------ Telephone.telephoneNum

Jul 16 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.