blob to float conversion

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Dear all,

I am very new in MySQL,  I am working on image database project for my
research and I have problem how to convert blob field into float  in
MySQL so that I can calculate the blob field with the MATH operation.

Does any one how to do it ????

Thank you very much indeed , for your help.


Re: blob to float conversion

yoes wrote:

Quoted text here. Click to load it

If I understood you correctly, you have a field in your table and you
want to change the type of this field and at the same time calculate a
different value for it, but use the old value to do so. If so...

To minimize the risk of the data loss, to keep system down as little as
possible and to make it easy, I suggest that you first create a new
field first. Then put the correct value to that field and then remove
the blob and then rename the new field to the name what blob had.
Something like:

alter table yourtablename add newfield float;
update yourtablename set newfield = 1+1; # add correct formula here
# Now is a good place to check that the newfield
# actually has correct values
alter table yourtablename drop blobfield;
alter table yourtablename change newfield blobfield float;

If the database has users 24/7 and you are creating the float value from
always changing data, you should lock the table for that operation to
prevent anyone changing the values while working.

Those commands were written from memory, without checking if they
actually work. Please use with caution.

Site Timeline