Professional Web Applications Themes

mysql40 timestamp - MySQL

Hi, I was recently forced to go back to 4.0 and I'm having a problem with a timestamp column that gets updated whenever the row gets modified. I want the timestamp to only carry the value for when the row is created in the db here is my current table creation statement: CREATE TABLE `wall_data` ( `id` int(11) NOT NULL auto_increment, `origin` varchar(60) default NULL, `poster` varchar(60) default NULL, `votes` varchar(60) default '0', `message` varchar(140) default NULL, `posted` timestamp default NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM; Thanks! Dan...

  1. #1

    Default mysql40 timestamp

    Hi,

    I was recently forced to go back to 4.0 and I'm having a problem with a
    timestamp column that gets updated whenever the row gets modified. I
    want the timestamp to only carry the value for when the row is created
    in the db here is my current table creation statement:

    CREATE TABLE `wall_data` (
    `id` int(11) NOT NULL auto_increment,
    `origin` varchar(60) default NULL,
    `poster` varchar(60) default NULL,
    `votes` varchar(60) default '0',
    `message` varchar(140) default NULL,
    `posted` timestamp default NULL,
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM;

    Thanks!

    Dan

    Daniel Guest

  2. #2

    Default Re: mysql40 timestamp


    Daniel wrote: 
    Can you post the queries that are used to update it?

    Captain Guest

  3. #3

    Default Re: mysql40 timestamp

    "Daniel" <com> wrote: 

    This is not possible in MySQL versions before 4.1.2. The semantics of
    the TIMESTAMP type was changed then. Please see the manual:

    <http://dev.mysql.com/doc/refman/4.1/en/timestamp-4-1.html>


    If you want to keep the value in the first TIMESTAMP column in MySQL
    4.0 you have to put the column in the UPDATE statement and assign it
    to itself:

    CREATE TABLE foo (id int, bar int, stamp TIMESTAMP);
    INSERT INTO foo (id, bar) VALUES (4711, 0);
    UPDATE foo SET bar=42, stamp=stamp WHERE id=4711;


    XL
    --
    Axel Schwenke, Senior Software Developer, MySQL AB

    Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
    MySQL User Forums: http://forums.mysql.com/
    Axel Guest

  4. #4

    Default Re: mysql40 timestamp

    Got it to work. Thanks!
    Axel Schwenke wrote: 
    >
    > This is not possible in MySQL versions before 4.1.2. The semantics of
    > the TIMESTAMP type was changed then. Please see the manual:
    >
    > <http://dev.mysql.com/doc/refman/4.1/en/timestamp-4-1.html>
    >
    >
    > If you want to keep the value in the first TIMESTAMP column in MySQL
    > 4.0 you have to put the column in the UPDATE statement and assign it
    > to itself:
    >
    > CREATE TABLE foo (id int, bar int, stamp TIMESTAMP);
    > INSERT INTO foo (id, bar) VALUES (4711, 0);
    > UPDATE foo SET bar=42, stamp=stamp WHERE id=4711;
    >
    >
    > XL
    > --
    > Axel Schwenke, Senior Software Developer, MySQL AB
    >
    > Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
    > MySQL User Forums: http://forums.mysql.com/[/ref]

    Daniel Guest

Similar Threads

  1. timestamp
    By EniGMistA in forum Dreamweaver AppDev
    Replies: 8
    Last Post: March 12th, 10:49 AM
  2. Querying a timestamp
    By trendline in forum Coldfusion Database Access
    Replies: 4
    Last Post: March 9th, 08:57 PM
  3. int4 -> unix timestamp -> sql timestamp; abstime?
    By Roman Neuhauser in forum PostgreSQL / PGSQL
    Replies: 8
    Last Post: January 12th, 01:02 AM
  4. [PHP] timestamp
    By John Taylor-Johnston in forum PHP Development
    Replies: 5
    Last Post: August 22nd, 08:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139