Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ADO.NET
hello evry body
this my first question in codeproject
 
i have 2 tables ( table1 , table2 )
 
table2 is part of table1
 
i want to show data from table1 where are not in table2
 
sorry for my English
Posted 10-Feb-12 8:03am
Comments
ryanb31 at 10-Feb-12 14:38pm
   
Several different ways to do that. You can do a WHERE NOT EXISTS or WHERE NOT IN but you need to get the SQL written and then we can help.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you have
 
Table1
 id
 name
and
 
Table2
 id
 name
 
Then you can do
 
SELECT Table1.* FROM Table1
LEFT JOIN Table2 
   ON Table1.ID = Table2.ID and Table1.Name = Table2.Name
WHERE Table2.ID is NULL
 
Essentially you're saying "Try to Join table 1 and Table 2 based on similar rows, and only return those rows from Table1 that don't exist in Table2"
  Permalink  
Comments
Espen Harlinn at 11-Feb-12 6:13am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

It's a simple task. Take a look at this article to learn everything about JOINs
Visual Representation of SQL Joins[^]
BTW it has the answer
  Permalink  
Comments
Espen Harlinn at 11-Feb-12 6:13am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You want to filter your data. The obvious way to do that is to just change the SQL that fills table2, to only put the data you want in there. Otherwise, copy the data to a new source and filter it.
 
And welcome to Code Project.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

thanks every one : i found the soulution with this query
 

SELECT * FROM Table1 WHERE ID NOT IN (SELECT ID FROM Table2)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 11 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100