Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > difference between two tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-12-08, 16:51
kimourina kimourina is offline
Registered User
 
Join Date: Jun 2008
Posts: 6
difference between two tables

Hi,

Iam looking out for difference in data between two similar tables.Since minus was not working, I tried using not exists using the following query to retrieve A-B functionality

select * from table A a1 where not exists (select * from table B b1 where a1.key1=b1.key1 and a1.key2=b1.key2 and a1.key3=b1.key1)

here my problem is i do not have a primary key field, but a unique combination of 3 fields.therefore, I tried the above option.

When i execute this ...the results are wierd..im confused.

Is there any other way i can acheive this, such that I can get records from table A which are not similar to that of table B.

Appreciate a quick help.

Thanks,
Kim
Reply With Quote
  #2 (permalink)  
Old 06-13-08, 04:44
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
Typo? "a1.key3=b1.key1"
Reply With Quote
  #3 (permalink)  
Old 06-13-08, 16:52
kimourina kimourina is offline
Registered User
 
Join Date: Jun 2008
Posts: 6
Hi,

Thanks...!!Its a typo...!!

it should be a1.key3=b1.key3....
Reply With Quote
  #4 (permalink)  
Old 06-17-08, 12:33
sudarao sudarao is offline
Registered User
 
Join Date: Mar 2007
Posts: 54
query

Try this,
#
select * from A where not exists (select 1 from b where a.1 = b.1 and a.2 = b.2 and a.3 = b.3)

HTH

suda
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On