Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 11th, 2006, 11:21 AM
klari klari is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 1 klari User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 41 sec
Reputation Power: 0
Select unmatched records from two tables of SQL

Hi All,

I have two tables Table1 and Table2 with some records

SLIPNO is the common column in both tables and primarykey is set to this column in table1

There are many records in table1 and some of these records (not all) are updated into table2.

Now I want retrieve from table1 the records not updated into the table2.

For example in table1 there are records 1,2,3,4,5,6,7,8,9
And in table2 there are 3,4,7,9

Now How can I retrieve these records form table1 1,2,5,6 those not updated into table2

I wrote this query :
SELECT Table1.SLIPNO, Table1.DATE, Table1.C_NAME, Table1.B_NAME
FROM [Table1] INNER JOIN Table2 ON Table1.SLIPNO <>Table2.SLIPNO;


But the expected result not coming. This query lists all the records repeating each one record manytimes

Can any body give me solution to get the expected result.

Klari

Reply With Quote
  #2  
Old December 12th, 2006, 06:27 AM
Jefy Jefy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 3 Jefy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 58 sec
Reputation Power: 0
U can use below query..

SELECT Table1.SLIPNO, Table1.DATE, Table1.C_NAME, Table1.B_NAME
FROM [Table1] LEFT OUTER JOIN Table2 ON Table1.SLIPNO =Table2.SLIPNO
where Table2.SLIPNO is null


Jefy

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Select unmatched records from two tables of SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT