I have a table like this
librarylog
| patronName | bookId | dueDate |
|---|---|---|
| John | 24 | 2024-01-14 |
| Sam | 42 | 2024-01-07 |
| Bob | 13 | 2024-01-07 |
I’m trying to create a SQL query which updates all the dueDate values and increases them by a week.
This is what I had:
UPDATE librarylog SET dueDate = DATE_ADD((SELECT * FROM (SELECT dueDate FROM librarylog)tblTmp), INTERVAL 1 WEEK);
But this returns
#1242 - Subquery returns more than 1 row
>Solution :
The RHS of the update should just be the dueDate column wrapped in DATE_ADD:
UPDATE librarylog
SET dueDate = DATE_ADD(dueDate, INTERVAL 1 WEEK); -- update all records