Reputation: 12538
I am having a hard time writing an UPDATE
query that includes an ORDER BY
clause.
Is this possible? I would appreciate any suggestions on how to do this.
This is a mock up of what I am trying to do:
UPDATE notes SET `note`='$note' WHERE `date` = (ORDER BY `date` DESC LIMIT 1)
Many thanks in advance!
Upvotes: 0
Views: 92
Reputation: 2594
you dont' really need order by, basing your sample query.
Update .... 'date' = (select max('date') from notes)
Upvotes: 0
Reputation: 182
Try this sql query:
UPDATE notes SET `note`='$note' WHERE `date` = (select `date` from notes ORDER BY DESC LIMIT 1)
Upvotes: 1