Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Sql query to compare between the tables

Sql query to compare between the tables

From: ganesh <ganu.kris_at_gmail.com>
Date: 1 Nov 2006 21:47:28 -0800
Message-ID: <1162446448.000110.245810@k70g2000cwa.googlegroups.com>


Hi,

My first table has the following snap shot. Uid is a GUID
Since Uid is a GUID , i did INDEXING and thats how i got idx 1,2,3....

dName Addr Uid idx



My second table for comparison will be

dName Addr Uid idx



the output between these two tables must be smethng like this

First table difference with second table

Valli 		surabhi
subhadeep 	fgeg
Prashh 		GreenPark
Kriss 		GardenValley


second table difference with first table
Valli 		Nilaya
Sw 		Bnagar


my query displayed the following O/p

First table with second table
idx dName Addr

----------- --------------------------------------------------

--------------------------------------------------
1 Valli Surabhi 4 subhaddep fgeg 5 Prashh GreenPark 6 Kriss GardenValley 7 ABC Mahaveer second table with first table idx dName Addr ----------- --------------------------------------------------
--------------------------------------------------
1 Valli Nilaya 4 ABC Mahaveer 5 Sw Bnagar

Hope u got the problem???

My query is smthing like this..
CREATE PROCEDURE [dbo].[CompareIndexedDatabase] AS
select u.idx,u.dName,u.Addr
from uidtable u,uidtable1 u1
where u.idx=u1.idx and
(
u.dname<>u1.dname or u.addr<>u1.addr
)
UNION
select u.idx,u.dName,u.Addr
from uidtable u
where u.idx not in
(
select u1.idx from uidtable1 u1)
UNION
select u.idx,u.dName,u.Addr
from uidtable1 u
where u.idx not in
(
select u1.idx from uidtable u1)

GO

Regards
Ganesh.k Received on Wed Nov 01 2006 - 23:47:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US