Forum Moderators: coopster

Message Too Old, No Replies

Copy row from table1 to table2 - mysql-php

without triggers

         

kahodges

5:46 pm on Aug 15, 2009 (gmt 0)

10+ Year Member



I'm trying to copy the contents of one table to another whenever there is deleted row, and then remove the row from the originating table. I have two tables identical, one for active employees, and one for terminated employees. I need to do this with php, as triggers are not an option on this shared host. I have the script protected with a .htaccess blocking all IP's except for mine. I'm not that versed on php and could use some help. Here's the schema of the tables. One is called active_employees and the other is called termed_employees:

id_employees int(10) Not Null
payroll_no varchar(10) NULL
employee_name varchar(75) NULL
Sex varchar(7) NULL
nextel varchar(13) NULL
ssNumber varchar(13) NULL
BirthDate varchar(30) NULL
Hire_Date varchar(30) NULL
QuitDate varchar(30) NULL
PayRate varchar(8) NULL
street_address varchar(100) NULL
City varchar(50) NULL
state varchar(25) NULL
zip_code varchar(10) NULL
home_phone varchar(15) NULL
cellphonenum varchar(15) NULL

What I'd like to do is whenever a termination date is entered into the active_employee table, it copies the entire row to the termed_employees table, and remove the row from the active_employees table.

Thanks in advance.

rocknbil

4:28 pm on Aug 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard kahodges,

insert into emp_backup_table (select * from emp_table where id_employees=1234)

should do it, then

delete from emp_table where id_employees=1234;