A
alhotch
I want to "prune" a reservations database - that is delete records that are
older than, say 11/01/2007. I have two tables - Reservations and
ReservationDetails - in a One-to-Many relationship. The ReservationDetails
table (field is PickUpDate) represents a travel date (outbound or inbound).
The Reservations table represents one or more ReservationDetail records.
Therefore, I can have several ReservationDetails records for ONE Reservation.
The JOIN looks like this: Reservations.ReservationID ===>
ReservationDetails.ReservationID in a One-to-Many. Primary keys are
Reservations.ReservationID and ReservationDetails.ResDetailID. Now I want to
delete those records (from ReservationDetails) whose PickUpDate is older than
11/01/2007. BUT, If there are additional detail records tied to the same
Reservation record that are newer than 11/01/2007, I want to keep the main
(Reservation) record. Example: I have detail records 618660 and 618661 that
are "owned" by Reservation record 363436. Detail record 618660 PickUpDate is
10/20/2007. Detail record 618661 PickUpDate is 11/10/2007. Even though I want
to "prune" the database back to 11/01/2007, I want to maintain the complete
record as referenced by the main Reservation record. So, after too many words
about describing my problem, what can I do to make this deletion query work
"as advertised" ?
older than, say 11/01/2007. I have two tables - Reservations and
ReservationDetails - in a One-to-Many relationship. The ReservationDetails
table (field is PickUpDate) represents a travel date (outbound or inbound).
The Reservations table represents one or more ReservationDetail records.
Therefore, I can have several ReservationDetails records for ONE Reservation.
The JOIN looks like this: Reservations.ReservationID ===>
ReservationDetails.ReservationID in a One-to-Many. Primary keys are
Reservations.ReservationID and ReservationDetails.ResDetailID. Now I want to
delete those records (from ReservationDetails) whose PickUpDate is older than
11/01/2007. BUT, If there are additional detail records tied to the same
Reservation record that are newer than 11/01/2007, I want to keep the main
(Reservation) record. Example: I have detail records 618660 and 618661 that
are "owned" by Reservation record 363436. Detail record 618660 PickUpDate is
10/20/2007. Detail record 618661 PickUpDate is 11/10/2007. Even though I want
to "prune" the database back to 11/01/2007, I want to maintain the complete
record as referenced by the main Reservation record. So, after too many words
about describing my problem, what can I do to make this deletion query work
"as advertised" ?