what if you really want to store the timestamp data, such
as the publication date of the article?
Answer Posted / tim little
A timestamp field can hold a date passed to it!
If you do :
CREATE TABLE newtable ( aname varchar(32), pubdate timestamp );
INSERT INTO newtable ( aname, pubdate ) values ( 'first', '2009-07-08' );
and then do a
SELECT * from newtable;
Then you get "2009-07-08 00:00:00" as the date back! You don't need a second field. Why do people think this? I've seen this all around the internet and it's always wrong!
Now, I will tell you that any updates to that ROW WILL clobber the field, UNLESS you make efforts to put the old value back in, like :
update newtable set aname = 'now', pubdate=pubdate where aname = 'first';
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is mysqli procedural?
What is text in mysql?
What are the 'mysql' command line options?
How to create table show example
What is the difference between heap table and temporary table?
How to validate email addresses in mysql?
How to get a version of mysql?
What is the use of mysqli_query?
Is mysql deprecated?
What are the disadvantages of stored procedures?
how you will show all records not containing the name "sonia" and the phone number '9876543210' order by the phone_number field.
What are the technical specifications of mysql?
How can I remotely connect to mysql database?
How do I restart mysql on windows?
What are numeric data types?