Home » SQL & PL/SQL » SQL & PL/SQL » comparing 2 tables
comparing 2 tables [message #304361] Wed, 05 March 2008 00:19 Go to next message
ridhi_sundar
Messages: 184
Registered: November 2007
Location: Bangalore
Senior Member
Hi
I hav 2 tables table a & table b.In these 2 tables i hav the same coloumns.col1, col2, col3. Now i hav to compare these 2 tables and get the data which r in table a but not in the table b. as well as i hav to get the name of the coloumn.

The problem is i hav to get a generalized approach so that i wont use the name of the columns in comparision.
Please suggest a way to solve this.

Regards

[Updated on: Wed, 05 March 2008 00:22]

Report message to a moderator

Re: comparing 2 tables [message #304363 is a reply to message #304361] Wed, 05 March 2008 00:22 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Use a MINUS query
Re: comparing 2 tables [message #304364 is a reply to message #304361] Wed, 05 March 2008 00:23 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
>Please suggest a way to solve this.

use MINUS
Re: comparing 2 tables [message #304379 is a reply to message #304364] Wed, 05 March 2008 00:41 Go to previous messageGo to next message
ridhi_sundar
Messages: 184
Registered: November 2007
Location: Bangalore
Senior Member
i m using the below code

Select * From FA_SYSTEM_CONTROLS minus Select * From FA_SYSTEM_CONTROLS_A

but an error is coming
ORA-01789:querry block has incorect no of result coloumns.

Again how can i get the coloumn name?

Regards
Re: comparing 2 tables [message #304383 is a reply to message #304379] Wed, 05 March 2008 00:55 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Select only col1, col2, col3.

Regards
Michel
Re: comparing 2 tables [message #304390 is a reply to message #304361] Wed, 05 March 2008 01:04 Go to previous message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
you have no same number and type of columns.
check your tables.

regards,

[Updated on: Wed, 05 March 2008 01:09]

Report message to a moderator

Previous Topic: Timestamp Error
Next Topic: Select from table using an array
Goto Forum:
  


Current Time: Sun Dec 04 15:01:19 CST 2016

Total time taken to generate the page: 0.06304 seconds