Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

192.168.1.41:8000, Www.xxxcon., %s wwwxxxcon, %s wwwxxxcon, www.xxxcon, xxxxdup, bitlord outgoing port settings, ckowwwxxx, 192.168.1.41:8000/nor-482.html, php.ini "Unable to initialize module"

Links

XODOX
Impressum

#1: Backing up from one table to another and adding date/time information

Posted on 2008-01-22 21:29:48 by kenoli

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

Report this message

#2: Re: Backing up from one table to another and adding date/time

Posted on 2008-01-22 22:00:19 by zeldorblat

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];

Report this message

#3: Re: Backing up from one table to another and adding date/time

Posted on 2008-01-23 01:15:30 by kenoli

On Jan 22, 1:00=A0pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
> 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. =A0Thus 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 =3D [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 =3D [some record number];

Thanks. I'll try it. And it won't get confused looking for a NOW()
field in tbl_1?

--Kenoli

Report this message

#4: Re: Backing up from one table to another and adding date/time

Posted on 2008-01-23 12:06:28 by Captain Paralytic

On 23 Jan, 00:15, Kenoli <kenol...@gmail.com> wrote:
> On Jan 22, 1:00 pm, ZeldorBlat <zeldorb...@gmail.com> wrote:
>
>
>
> > 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];
>
> Thanks. I'll try it. And it won't get confused looking for a NOW()
> field in tbl_1?
>
> --Kenoli

http://dev.mysql.com/doc/refman/5.0/en/select.html

Report this message

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

Posted on 2008-01-23 16:36:45 by IanP

Kenoli 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
>
There is a field type that does this automatically - it auto updates
with the current_timestamp - have a look at TIMESTAMP

Report this message

#6: Re: Backing up from one table to another and adding date/time

Posted on 2008-01-23 19:36:31 by kenoli

On Jan 23, 7:36=A0am, Ian Pawson <i...@ipawson.com> wrote:
> Kenoli 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. =A0Thus 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 =3D [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
>
> There is a field type that does this automatically - it auto updates
> with the current_timestamp - have a look at TIMESTAMP

Thanks

Report this message