Reply to Re: Backing up from one table to another and adding date/time information

Your name:

Reply:


Posted by ZeldorBlat on 01/22/08 21:00

On Jan 22, 3:29 pm, Kenoli <kenol...@gmail.com> wrote:
> I want to insert the data from one record in one table into another
> table in a mysql database, adding the current date and time to a field
> in the table the data is going into. Thus when a record is changed, I
> am backing it up and indicating the date and time of the backup in a
> "date" field.
>
> The following is the method for copying data from a field in one table
> to another.
>
> INSERT INTO tbl_2 (fld_1, fld_2) SELECT tbl_1.fld_1, tbl_1.fld_2 FROM
> tb_1 WHERE tbl_1.fld_id = [some record number];
>
> How can I mix this with adding the new date/time data to a date field
> in table 2 as well?
>
> Thanks,
>
> --Kenoli

Just include another column with the value of NOW():

INSERT INTO tbl_2 (fld_1, fld_2, fld_date)
SELECT tbl_1.fld_1, tbl_1.fld_2, NOW()
FROM tb_1
WHERE tbl_1.fld_id = [some record number];

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация