Hi
I have 2 tables: Person and PersonCar - something like this:
CREATE TABLE `database1`.`Person` (
`id` INTEGER UNSIGNED NOT NULL,
`name` VARCHAR(100)) NOT NULL,
`added_date` DATETIME NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `database1`.`PersonCar` (
`id` INTEGER UNSIGNED NOT NULL,
`person_id` INTEGER UNSIGNED NOT NULL,
`plate_no` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`)
)
This is how I delete for those from 2008 or older (delete car aswell if person has a car):
DELETE Person, PersonCar FROM Person LEFT OUTER JOIN PersonCar ON Person.id = PersonCar.person_id WHERE Person.added_date < '2009-01-01 00:00:00'
My question is: how do I make backup to 2 other identical tables Person_backup and PersonCar_backup in 1 query - in the same manner as the above delete query (copying car is person has a car)?