On Mon, May 20, 2013 at 12:59:45PM +0100, Paul Sanderson scratched on the wall:
> I have a table of the form
> 
> create table tab (num int1 unique, num2, int)
> 
> for each row for num2 there is usually a matching num1. But not always.
> 
> I want to identify each row where num2 does not have a matching num1
> 
> example data might be
> 
> num1  num2
> 1          3
> 2          3
> 3          2
> 4          1
> 5          11
> 6          3
> 7          9
> 
> in this example my query would return rows 5 and 7 as there is no match on
> num1 for 11 and 9

  Join the table to itself using an outer join on the condition that
  num2 == num1.  Look for rows where num1 is NULL, indicating no join
  was found.  Only works if num1 is never NULL in the DB.

  I need to run.  Perhaps someone else can provide an example if that's
  not making sense.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to