Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8160725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:20:22+00:00 2026-06-06T18:20:22+00:00

I think I may have encountered a bug in mysql, or is it just

  • 0

I think I may have encountered a bug in mysql, or is it just me doing it wrong.

I’ve been using the same specific queries for the last four months and just today it stopped working somehow. I can’t see the problem.

I’m executing these queries in the mysql console it works great, and the field is being updated. but when these queries are being executed by PHP it fails.

After insertion of a record into a table(with two timestamp fields), I’m trying to update a specific timestamp column.

But unfortunately it fails to update the column.

The query goes well(no errors), but still the value in the timestamp column stays the same. That’s weird, cause when I’m leaving the initial column value as NULL, the update query succeed.

Columns :

START_DATETIME, END_DATETIME - are "timestamp" type.

Insert:

INSERT INTO TABLE1(START_DATETIME, END_DATETIME, RESPONSE) 
VALUES(NOW(), NOW(), 'STARTED')

Insert is done successfully. id is 123

The update query is normal like any other query:

UPDATE TABLE1 
SET END_DATETIME = NOW(), RESPONSE='ENDED'
WHERE ID = 123

Update fails, END_DATETIME doesn’t get the NOW() value.

Can be reproduced with this:

CREATE TABLE TABLE1 
(
    id int auto_increment, 
    start_datetime timestamp, 
    end_datetime timestamp, 
    response varchar(100), 

    primary key(id)
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:20:23+00:00Added an answer on June 6, 2026 at 6:20 pm

    You probably have defined the first timestamp column (the START_DATETIME one) to be auto-inserted and auto-updated with the CURRENT_TIMESTAMP value (which is the same as NOW().

    Notice that if you don’t explicitedly state anything about the TIMESTAMP columns in the CREATE TABLE script, the first one of them gets by default this behaviour/attributes. Read the MySQL documentation about this Automatic Initialization and Updating for TIMESTAMP, where it states:

    • With neither DEFAULT CURRENT_TIMESTAMP nor ON UPDATE CURRENT_TIMESTAMP, it is the same as specifying both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP.

    So, if you do a SHOW CREATE TABLE tableName, you’ll have something like this:

    CREATE TABLE table1
    ( ...
    , START_DATETIME TIMESTAMP NOT NULL 
                       DEFAULT CURRENT_TIMESTAMP
                       ON UPDATE CURRENT_TIMESTAMP
    , ...
    ) ;
    

    You should alter the column definition to not be auto_updated, if you don’t want this behaviour:

    ALTER TABLE table1
      MODIFY COLUMN  
        START_DATETIME TIMESTAMP NOT NULL
                         DEFAULT CURRENT_TIMESTAMP ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I may have encountered a possible bug with db4o 8.0 for .NET,
I think I may have found a bug with Google Chrome (16.0.912.75 m, the
I think I may have found a bug in WebMatrix's PageData, but I am
Hi I think I may have done this the wrong way round can anyone
I think I may have a misunderstanding of <xsl:variable\> and <xsl:value-of\> so perhaps someone
I think I may have accidently disabled stylecop in my Visual Studio 2008 enviroment.
I think we may have trouble with our existing project. For some reasons we
I think I may have used a repeater when I should have used something
I think this may be relatively straight forward. I have a rewrite rule that
Hopefully this question isn't as subjective as I think it may be. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.