Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: Comparing 2...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 3688 of 3876
Post > Topic >>

Re: Comparing 2 tables

by Lew <lew@[EMAIL PROTECTED] > Mar 28, 2008 at 10:23 PM

Roedy Green wrote:
> On Thu, 27 Mar 2008 22:00:32 -0700 (PDT), m <modhak@[EMAIL PROTECTED]
> wrote,
> quoted or indirectly quoted someone who said :
> 
>> I write jdbc program which reads tables and compare row by row, just I
>> think it is laborious. Is there a better way of doing this. Please let
>> me know.
> 
> do it in SQL with a where clause..  Presumably you want only that
> match or differ.
> 
> This will probably be faster because no records have to be trans****ted
> to your application which may be running on a different box.

Given tables A and B that share a primary key (PK):
CREATE TABLE A ( id INTEGER PRIMARY KEY, etc. )
CREATE TABLE B ( id INTEGER PRIMARY KEY, etc. )

SELECT COUNT(*) FROM A WHERE id NOT IN (SELECT id FROM B);
and vice versa.

-- 
Lew
 




 4 Posts in Topic:
Comparing 2 tables
m <modhak@[EMAIL PROTE  2008-03-27 22:00:32 
Re: Comparing 2 tables
David Harper <devnull@  2008-03-28 07:05:54 
Re: Comparing 2 tables
Roedy Green <see_websi  2008-03-28 12:33:00 
Re: Comparing 2 tables
Lew <lew@[EMAIL PROTEC  2008-03-28 22:23:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 22:44:37 CST 2008.