On 3/03/2009 12:48 PM, yaconsult wrote:
> SQL newbie here.  I have data in a couple of tables that I need to relate. 
> But I don't know how to relate on more than one column.  I'll not go into
> detail about why the data is formed the way it is - it comes from other
> programs.
> 
> For example, let's say there are a couple of tables:
> 
> server login name last_login email ...
> 
> and we have a second table that contains columns for server and login:
> 
> server login
> 
> How can I, for example, select rows of the first table where their server
> and login, combined, are NOT in the second table.
> It's sorta like a composite key.  Do I do it with a couple of joins?  Could
> I see an example?
> 
> If it were only a single column I could use a "not in" subselect, but I'm
> not sure how to do it when it involves more than one column.

You're on the right track now, you need something like a "not in" 
subselect; a join is the *opposite* of what you want.

select * from first f where not exists (select 1 from second s where 
f.login = s.login and f.server = s.server) -- untested, OTTOMH, YMMV, 
etc :-)

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to