Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a corrupt blob in a row.
I'd like to replace that with another blob from the same table.

How can I do that with sql statements only? (No file system access if at all possible.)

share|improve this question
up vote 2 down vote accepted

Poor man's change:

mysql> CREATE TABLE `foo` (
  `id` tinyint(4) NOT NULL AUTO_INCREMENT,
  `content` blob,
  PRIMARY KEY (`id`)

mysql> INSERT INTO foo VALUES (NULL, 'bar'), (NULL, 'another_bar');

mysql> SELECT * FROM foo;
| id | content     |
|  1 | bar         |
|  2 | another_bar |
2 rows in set

mysql> SELECT content INTO @newContent FROM foo WHERE id=2;

mysql> UPDATE foo SET content=@newContent WHERE id=1;

mysql> SELECT * FROM foo;
| id | content     |
|  1 | another_bar |
|  2 | another_bar |
2 rows in set

And now I've done it without using session variables:

 UPDATE foo, (SELECT content AS selectContent FROM foo WHERE id=2)selectFoo 
  SET content=selectContent 
  WHERE id=1;
share|improve this answer
Not a poor man's change, just cost effective. +1 !!! – RolandoMySQLDBA Feb 1 '12 at 16:50
@Rolando It's 'poor', because there seems to be a better way...which I just updated into my answer without using session variables. Thanks for the upvote! – Derek Downey Feb 1 '12 at 16:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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