Alan,
Try:

select * from table1 where ref in (select ref from table1 left join table2
on table2.ref=table1.ref where isnull(table2.ref))

Dave Crozier

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Alan Bourke
Sent: 30 November 2006 16:26
To: [email protected]
Subject: SELECT-Sql IN clause help

I know this is simple but I'm having a thick day. 

Two tables

table1 (ref C(16))

table2 (parent C(16), ref C(16))

What's the VFP9 SELECT command to get the records out of table1 that do
not have a matching record in table2, matching the ref fields.

This works to get the ones that DO:

select * from table1 where ref in (select ref from table2)

but the opposite just returns one record, i.e.

select * from table1 where ref not in (select ref from table2)
-- 
  Alan Bourke
  [EMAIL PROTECTED]

-- 
http://www.fastmail.fm - Does exactly what it says on the tin



[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to