I have a table with 5 million DATETIME
records. I want to add a year to all the various datetimes in the table. Can I do it all with a single query? Something like:
SELECT DATE_ADD(*, INTERVAL 1 YEAR);
Or any other way you would recommend. Thanks!
Syntax: UPDATE table_name SET column_name1 = new_value1, column_name2 = new_value2 ---- WHERE condition; Here table_name is the name of the table, column_name is the column whose value you want to update, new_value is the updated value, WHERE is used to filter for specific data.
SQL gives users the option to update existing records in tables with the help of the UPDATE command. Using this command, you can change and alter some (or all) of the records from single or multiple columns of a table.
Yes underlying table data can be updated by Updating a view.
This should do what you want:
UPDATE table SET datefield = DATE_ADD(datefield, INTERVAL 1 YEAR);
If you need to update every table in the database check the answers to this question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With