Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detete record based on another table 1

Status
Not open for further replies.

Barra44

Programmer
Dec 18, 2001
50
AU
I have 2 tables

Table 1
Leavetbl - field tempdate

Table 2
Holidays - field holidate

tables linked one to many holidate-tempdate


I wish to delete records from table 1 where leavedate = holidate

This is what I have written but when I run it i am prompted to enter a value for holidate.


DELETE [Leavetbl].tempdate
FROM Leavetbl
WHERE (([Leavetbl].tempdate)=(Holidays.holidate));



Thanks in advance
 
I'm no pro, but you do need to reference the Holiday table in your table list, along these lines:
Code:
DELETE [Leavetbl].tempdate
FROM Leavetbl[COLOR=blue], Holidays[/color]
WHERE (([Leavetbl].tempdate)=(Holidays.holidate));
No guarantees that it will work, but it's more correct, anyway. ;-)
 
I added Holidays in the from line and ran it, now it asks me to "specify the table containig the record you want to delete
 
Perhaps
Code:
DELETE Leavetbl.* 
FROM Leavetbl
INNER JOIN Holidays 
ON Leavetbl.tempdate = Holidays.holidate
WHERE Leavetbl.tempdate = Holidays.holidate
 
When I try to do this same thing- it says "Cannot delete from specified tables."

Well why not!? :(
 
Quote: When I try to do this same thing- it says "Cannot delete from specified tables."

Well why not!? :(

I am having the same problem also. Here is my code...

DELETE [Oxygen].*
FROM [Oxygen] INNER JOIN AdminCodes ON [Oxygen].[GP Code] = AdminCodes.[GP ADMIN CODE];

Can anyone suggest a solution please?
 
DELETE FROM [Oxygen]
WHERE [GP Code] In (SELECT [GP ADMIN CODE] FROM AdminCodes);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top