Code:
Table [I]Dogs:[/I]
[B]Name FirstStop SecondStop[/B]
Spot London Paris
Spot Paris Beijing
Spot Rome Beijing
Alf Miami Key West
Table [I]PlacesToGo:[/I]
[B]Name Location[/B]
Spot London
Spot Paris
Alf Miami
I need a query to delete all records from "Dogs" where FirstStop AND SecondStop are not a Location.
So in the tables above, the row with Spot - Rome,Beijing would be deleted because Rome is not in PlacesToGo for spot and Beijing is not either.
Spot- Paris,Beijing is okay because Paris is one of the places spot can go.
Spot- Beijing,Paris would also be okay (just showing order doesn't matter)
I have a query that comes close to doing this, but doesn't quite get there
Code:
DELETE
FROM Dogs
WHERE EXISTS
(
SELECT *
FROM [PlacesToGo]
WHERE
(
(Dogs.[FirstStop]=PlacesToGo.[Location] Or
Dogs.[SecondStop]=PlacesToGo.[Location])=False
)
);
I think I'm going to need an iif(), is it possible to have another select query insie the iif?
I could use anyone's help on this. If I do anything logical... it seems to delete all my records.
Thanks in advance,
Modest