C
Crystal via AccessMonster.com
Pelase help me with the delete query.
I have tbl plans and tbl category and they join by 3 fields (last name, fst3
and dob). Now I need to delete from tbl plans all the matching records found
by the join query. When I run delete query, I got error msg: could not delete
from specified tables. I changed the property to distinctrow but it did not
work.The following SQL gives error msg:
DELETE DISTINCTROW a.*
FROM [plans] AS a INNER JOIN [category] AS b ON (a.[Last Name] = b.[Last Name]
) AND (a.fst3 = b.fst3) AND (a.DOB = b.DOB);
I cannot use IN because I need all three fields from the two tables match. So
I changed my query to use EXISTS, but it deletes all the records from the
table instead of just the ones matching between the two tables). When I run
the SQL after EXISTS, it gives me just the right amount of records. This SQL
delete everything:
delete *
FROM [04b plans]
where exists
(select * from [04b plans] c
INNER JOIN [05c blue covg] d ON c.DOB =d.DOB AND c.fst3 =d.fst3 AND c.[Last
Name] =d.[Last Name])
I have searched this wonderful site and could not find a solution. Thank you
very much for your help.
I have tbl plans and tbl category and they join by 3 fields (last name, fst3
and dob). Now I need to delete from tbl plans all the matching records found
by the join query. When I run delete query, I got error msg: could not delete
from specified tables. I changed the property to distinctrow but it did not
work.The following SQL gives error msg:
DELETE DISTINCTROW a.*
FROM [plans] AS a INNER JOIN [category] AS b ON (a.[Last Name] = b.[Last Name]
) AND (a.fst3 = b.fst3) AND (a.DOB = b.DOB);
I cannot use IN because I need all three fields from the two tables match. So
I changed my query to use EXISTS, but it deletes all the records from the
table instead of just the ones matching between the two tables). When I run
the SQL after EXISTS, it gives me just the right amount of records. This SQL
delete everything:
delete *
FROM [04b plans]
where exists
(select * from [04b plans] c
INNER JOIN [05c blue covg] d ON c.DOB =d.DOB AND c.fst3 =d.fst3 AND c.[Last
Name] =d.[Last Name])
I have searched this wonderful site and could not find a solution. Thank you
very much for your help.