Home » SQL & PL/SQL » SQL & PL/SQL » select data within 2 different database (oracle 9i)
icon5.gif  select data within 2 different database [message #391107] Wed, 11 March 2009 01:20 Go to next message
fadhzone
Messages: 61
Registered: April 2008
Member
Hi All,

I need help to write a script that will compare and select
the different data within 2 different database.
e.g : to select sku_cd from
table sku_merch@xxx.aa.com and
table sku_merch@xxx.bb.com.

the data must tally within 2 database.but now it doesn't.i need to know which sku_cd doesn't tally.

thank you
Re: select data within 2 different database [message #391111 is a reply to message #391107] Wed, 11 March 2009 01:36 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@fadhzone,

A MINUS Query or EXISTS Condition might help you here.

Regards,
Jo
Re: select data within 2 different database [message #391112 is a reply to message #391111] Wed, 11 March 2009 01:37 Go to previous messageGo to next message
fadhzone
Messages: 61
Registered: April 2008
Member
thanks joicejohn for the reply.

but..can u explain more..i don't understand.

Thanks.
Re: select data within 2 different database [message #391116 is a reply to message #391112] Wed, 11 March 2009 01:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did read and try the links?
First do it and then come back with what you tried then we can help you to fullfil your requirements.

Another article: Comparing the Contents of Two Tables

Regards
Michel
Re: select data within 2 different database [message #391117 is a reply to message #391112] Wed, 11 March 2009 01:51 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@fadhzone,

Please don't use IM Speak in this forum.

Please go through th links I have posted earlier.

A Simple example of MINUS Query is like:
SQL> SELECT * FROM test_tab;

COL_A
----------
A
B
C

3 rows selected.

SQL>  SELECT * FROM test_tab_new;

COL_A
----------
A
B
C
D
E
F
G
H
I
J

10 rows selected.

SQL> SELECT Col_A FROM test_tab_new
  2  MINUS
  3  SELECT Col_A FROM test_tab;

COL_A
----------
D
E
F
G
H
I
J

7 rows selected.

SQL> 


Hope this example helps.

Regards,
Jo
Re: select data within 2 different database [message #391119 is a reply to message #391117] Wed, 11 March 2009 01:56 Go to previous message
fadhzone
Messages: 61
Registered: April 2008
Member
Jo & Michel,
Thanks for the kind helps. I always wondering if the oracle can use UNION,it must have a way to use intersect.
Now i know how to use both; MINUS and INTERSECT instead of UNION.
I get the answer.
Thank you once again and have a nice day
Previous Topic: traingle qery
Next Topic: EXISTS statement...
Goto Forum:
  


Current Time: Fri Dec 09 17:14:22 CST 2016

Total time taken to generate the page: 0.17221 seconds