6

I need to copy a set of data from one table to another that includes a BLOB column. I'm using an INSERT query with a subquery SELECT:

INSERT INTO dest_table(field1, field2, field3, blobfield, field4) 
    (SELECT t.myfield1, t.myfield2, t.id, t.blobfield, 'SomeConstant' 
        FROM tablename t)

All fields get copied correct, except the BLOB. I know I'm missing something, but I have no idea on how to make this work. Search did not help me. Anyone know how to solve it?

I'd prefer a solution in pure SQL, but I can use Ruby too.

1
  • +1 I was about to ask how to copy from one table to another until I found this related question
    – Ozzy
    Apr 23, 2012 at 13:03

1 Answer 1

7

After playing a bit here, I found the error: the original column is a MEDIUMBLOB, not a BLOB. It works fine when I just correct the type. Sorry for the dumb question.

2
  • 1
    No question is dumb question! Its matter of Ignorance.
    – Niger
    Aug 17, 2009 at 1:25
  • Don't sorry, it helps me a lot. Thanks!. Apr 4, 2021 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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