0

Trying to update the "size" column with the value of "file" column.

BEGIN
  set NEW.size=SUM(LENGTH(file));
END

Executing:

UPDATE `table`.`library` SET `_by`='Danis555, Vovan244' WHERE `id`='20';

Operation failed: There was an error while applying the SQL script to the database.

ERROR 1111: 1111: Invalid use of group function SQL Statement: UPDATE table.library SET _by='Danis555, Vovan244' WHERE id='20'

3
  • What's the reasoning behind SUM(LENGTH())?
    – mustaccio
    May 8, 2017 at 14:22
  • To get the size of of my blob column(file). May 8, 2017 at 14:55
  • How many LENGTHs do you expect to be returned for one column in one row that you need to SUM them?
    – mustaccio
    May 8, 2017 at 16:57

1 Answer 1

0
SET NEW.size = LENGTH(OLD.file);

No SUM, since there is only one row.
Specify which file with OLD..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.