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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Query 1

Status
Not open for further replies.

macca007

Programmer
May 1, 2004
86
GB
Hi all i have tblPatients and tblTreatments wat i would like to do is create sql to delete all data (all fields in both table) that is Not Between "#01/01/1999#" And "#31/12/1999#" .

Cheers
 
And where are you stuck ?
Create a query for each table with the range date criteria and when you're sure to get the correct records change the query to a delete query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Never done delete query before, i prefer it in sql then will have a look in access.

some suggestions will be welcomed.

patient has one to many treatments relationship
 
In the relationship that you have setup make sure that Referential Integrity is selected and Cascading Deletes also. This way you only have to Delete the one record on the one side of the relationship to get all the records deleted.

Code:
Delete * from tblPatients 
WHERE tblPatients.[[i][red]yourdatefield[/red][/i]] Not Between #01/01/1999# And #12/31/1999#;

Now all records in both tables will be deleted.


[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top