> SELECT * FROM Features WHERE
> NOT EXISTS (SELECT * FROM PubFeatures WHERE Features.FeatureID
> =PubFeatures .PubFeatureID)
I've cracked this with your suggestion... your NOT EXISTS got me on the
right track. A bit more was required as what's needed is the Pub ID as well
as the missing Symbol IDs.
Select
P.[PubID], F.[FeatureID]
From [Pubs] P, [Features] F
Where Not Exists
(Select * From [PubFeatures] PF Where F.[FeatureID]=PF.[FeatureID] And
P.[PubID]=PS.[PubID])
The key addition is the From Table1, Table2 format which returns a list of
pubs with a list of possible features for each pub. This is then fed into
the Not Exists you suggested.
The output is something like this:
PubID, FeatureID
32,34
32,35
33,34
Which means that Pub ID=32 needs new features adding but Pub ID=33 only
needs one.
This select can be then fed directly into an INSERT command.
It's cut down execution in the test database (which only had 250 pubs) from
15 seconds to almost instantaneous.
Cheers, Rob.