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: profox-bounces at leafe .D.O.T com [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 30 November 2006 16:26 To: profox at leafe .D.O.T com 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 alanpbourke@fastmail.fm
-- http://www.fastmail.fm - Does exactly what it says on the tin
[excessive quoting removed by server]
©2006 Dave Crozier |