Jump to content
Larry Ullman's Book Forums

Recommended Posts

I was unable to get the code to work to generate the MySQL table for Chapter 1.  I gathered that I was getting some kind of error due to two timestamps being created in the same table.  I was able to get the following table creation command to work, but wondered if anybody had further clarification of a better way to create the table.  Thanks!

 

CREATE TABLE tasks ( task_id INT UNSIGNED NOT NULL AUTO_INCREMENT, parent_id INT UNSIGNED NOT NULL DEFAULT 0, task VARCHAR(100) NOT NULL, date_added DATETIME NOT NULL, date_completed TIMESTAMP, PRIMARY KEY (task_id), INDEX parent (parent_id), INDEX added (date_added), INDEX completed (date_completed));

Share this post


Link to post
Share on other sites

This is probably due to the version of MySQL that you're using, as support for multiple timestamps with automatic behavior has changed over time. It's hard to know what the solution is without know the actual error, but using a combination of TIMESTAMP and DATETIME seems perfectly reasonable. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...