Reputation: 193
I like to update the field "filepath" of my table "imagedata" of the last entry made?
UPDATE `imagedata` SET `filepath`='sdsd' WHERE `id` = MAX(imagedata.id);
Somehow my synax ist not right it says:
Invalid use of group function`
what do i do wrong?
Upvotes: 1
Views: 5069
Reputation: 9392
If you use an AUTO_INCREMENT column, You could try
UPDATE `imagedata` SET `filepath`='sdsd' WHERE `id` = LAST_INSERT_ID();
Upvotes: 1
Reputation: 56397
UPDATE `imagedata`
SET `filepath`='sdsd'
order by id desc limit 1
Another alternative:
UPDATE `imagedata`
SET `filepath`='sdsd'
where id = (select * from (select max(id) from imagedata) as t)
Upvotes: 4