DELETE FROM TableB
WHERE OrderNo NOT IN
(SELECT DISTINCT OrderNo
FROM TableA)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"kikeman" <(E-Mail Removed)> wrote in message
news:8EEFC8B3-8599-491F-ABA1-(E-Mail Removed)...
> Hi,
>
> I have two tables: TableA and TableB they both have a column called
> "OrderNo" (same type and info, of course), I would like to delete those
> entries in TableB that ARE NOT in TableA according to the "OrderNo".
>
> "OrderNo" is the Primary Key in TableA, but it is allow to have duplicates
> in TableB of "OrderNo"
>
> It is to say, I would have in TableB "OrderNo" values only if they exist
> in
> TableA, now I want to avoid to have "OrderNo" in TableB that does no exist
> in
> TableA.
>
> What would SQL command to do this?
> I am using OleDB in C#.
>
> Thanks,
> Enrique.