Delete Query

B

Bdavis

Unfortunetly I was unable to apply the solutions from other who had similar
problems:

Basically, I have delete query (SQL below) which is generating the error:
"Specify the table contiang the records you want to delete" and I can't get
the SQl right.

DELETE Employees.ID, dbo_persons.*
FROM dbo_persons LEFT JOIN Employees ON dbo_persons.SPID = Employees.ID
WHERE (((Employees.ID) Is Null));

And suggestions are much appreciated
 
M

MGFoster

Bdavis said:
Unfortunetly I was unable to apply the solutions from other who had similar
problems:

Basically, I have delete query (SQL below) which is generating the error:
"Specify the table contiang the records you want to delete" and I can't get
the SQl right.

DELETE Employees.ID, dbo_persons.*
FROM dbo_persons LEFT JOIN Employees ON dbo_persons.SPID = Employees.ID
WHERE (((Employees.ID) Is Null));

And suggestions are much appreciated

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Indicate which table you want to delete from by have just that table
name in the DELETE clause:

DELETE dbo_persons.*
FROM dbo_persons LEFT JOIN Employees ON dbo_persons.SPID = Employees.ID
WHERE Employees.ID Is Null

Uncheck the Show check box under the ID column in the Design Grid.

Since dbo_persons indicates it is an SQL Server table ('dbo_') then you
have to have DELETE permission in SQL Server for that table.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSdvddYechKqOuFEgEQIGjQCfR2458ozQJ/+6SgVKmmaE+UTb/JIAoP9Q
yvj9jcfcsayHvdRxEzrYAioo
=0Ztb
-----END PGP SIGNATURE-----
 
J

John Spencer

Assumption: You wish to delete records in table in dbo_persons. You
didn't say.

DELETE
FROM dbo_Persons
WHERE SPID IN
(SELECT SPID
FROM dbo_Persons LEFT JOIN Employees
ON dbo_Persons.SPID = Employees.ID
WHERE Employees.ID is Null)

Basically the sub-query identifies all the SPID that have no matching
value in Employees table and the In comparison uses that to identify the
records to delete.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top