If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > please help with query!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-23-09, 10:13
pilugr pilugr is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
please help with query!

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)?
Reply With Quote
  #2 (permalink)  
Old 04-23-09, 10:24
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
can't be done in one query
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-23-09, 10:28
pilugr pilugr is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
i can do this programmatically with csharp (more than one query) - but is it possible to make this backup without involving programming? the goal is to just open the mysql query browser and fire a sql syntax - if this requires more than one query thats fine..
Reply With Quote
  #4 (permalink)  
Old 04-23-09, 14:38
pilugr pilugr is offline
Registered User
 
Join Date: Apr 2009
Posts: 3
bump - please anyone?
Reply With Quote
  #5 (permalink)  
Old 04-23-09, 14:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
bumping is frowned upon

and anyhow, you answered your own question -- use two queries

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On