Grokbase Groups MySQL mysql June 2002
FAQ
Hi all
I can't work out why this query is also updating a TIMESTAMP col?

UPDATE news SET title = 'new title', text = 'new text' WHERE id = '4'

The table is very simple:

* id INT
* date TIMESTAMP // this is current date when 'updating'?
* title VARCHAR
* text TEXT

I need the date col to remain the same, what am I doing wrong?

Much thanks...
- --
Nick Wilson // www.explodingnet.com

Search Discussions

  • Jay Blanchard at Jun 14, 2002 at 12:33 pm
    {snip]
    I can't work out why this query is also updating a TIMESTAMP col?

    UPDATE news SET title = 'new title', text = 'new text' WHERE id = '4'
    [/snip]

    Because, according to TFM; (http://www.mysql.com/doc/D/A/DATETIME.html)

    Automatic updating of the first TIMESTAMP column occurs under any of the
    following conditions:

    *The column is not specified explicitly in an INSERT or LOAD DATA INFILE
    statement.
    *The column is not specified explicitly in an UPDATE statement and some
    other column changes value. (Note that an UPDATE that sets a column to the
    value it already has will not cause the TIMESTAMP column to be updated,
    because if you set a column to its current value, MySQL ignores the update
    for efficiency.)
    *You explicitly set the TIMESTAMP column to NULL.

    HTH!

    Jay
  • Nick Wilson at Jun 14, 2002 at 1:58 pm
    * and then Jay Blanchard declared....
    other column changes value. (Note that an UPDATE that sets a column to the
    value it already has will not cause the TIMESTAMP column to be updated,
    because if you set a column to its current value, MySQL ignores the update
    for efficiency.)
    *You explicitly set the TIMESTAMP column to NULL.

    HTH!
    Sure does, cheers Jay.
    - --
    Nick Wilson // www.explodingnet.com
  • Egor Egorov at Jun 14, 2002 at 2:05 pm
    Nick,
    Friday, June 14, 2002, 3:40:23 PM, you wrote:

    NW> I can't work out why this query is also updating a TIMESTAMP col?

    It's a paticular feature of TIMESTAMP column. Read the manual:
    http://www.mysql.com/doc/D/A/DATETIME.html

    NW> UPDATE news SET title = 'new title', text = 'new text' WHERE id = '4'

    NW> The table is very simple:

    NW> * id INT
    NW> * date TIMESTAMP // this is current date when 'updating'?
    NW> * title VARCHAR
    NW> * text TEXT

    NW> I need the date col to remain the same, what am I doing wrong?

    NW> Much thanks...





    --
    For technical support contracts, goto https://order.mysql.com/?ref=ensita
    This email is sponsored by Ensita.net http://www.ensita.net/
    __ ___ ___ ____ __
    / |/ /_ __/ __/ __ \/ / Egor Egorov
    / /|_/ / // /\ \/ /_/ / /__ egor.egorov@ensita.net
    /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
    <___/ www.mysql.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmysql @
categoriesmysql
postedJun 14, '02 at 12:28p
activeJun 14, '02 at 2:05p
posts4
users3
websitemysql.com
irc#mysql

People

Translate

site design / logo © 2021 Grokbase