2

I am looking for really good examples on how to work with date or datetime or how to update them correctly on a databases so that they can be "up to date". I have had this issues before with sql, when using date or datetime they would not update after I use them. The only time I could modify them would be when inserting into the table. Also, the same applied when I used a JDBC connector to create an interface for the database. The data would modify only at inserting and not when altering. What to use when altering a table? Update?

Example: I have an online store in which I have "Products for sale" with fields in which day I created the Product and what day I restocked(when creating restocked will have the same value as created.). I create a new product, after 3 days I restock. How can I correctly alter the product so that the day I restocked is today, not 3 days away when I first created the product? I am using MySQL WORKBENCH 6.0 CE. Any suggestions will be appreciated. Thank you!

Diana G
  • 261
  • 3
  • 15
  • to record when a row was created or modified you'll want to have a look at the TIMESTAMP type in MySQL. Have a look at this answer https://stackoverflow.com/a/20347643/3161253. The MySQL documentation on the TIMESTAMP and TRIGGERS that fire when the rows change are also a good reference. – Sean Apr 28 '18 at 14:33

0 Answers0