At 08:50 AM 5/11/2005, you wrote:
Steve Buehler <[EMAIL PROTECTED]> wrote on 05/11/2005 09:36:44 AM:
> I am trying to figure something out about the compress function. If I
> wanted to compress a field in a column/row and write it back to the table,
> how can I do this? Is it possible to do it in one command? I tried:
> update `conflicts` set `fname`=(SELECT compress(`fname`) FROM `conflicts`
> WHERE `conflict_id`='2') where `conflict_id`='2'
>
> But that didn't work. This question is more a learning thing that anything
> else. I am not even sure what I would use the "compress" function
> for. Maybe somebody can also give me an example of the uses for
> it......why it would be used. Also, If I wanted to compress the `fname`
> field for every row in the database, how would that be done?


Depending on your version of MySQL, that UPDATE statement won't work at all ( 1:it uses a subquery AND 2:the subquery references the target table [separate issues]). Since you want to duplicate the value from one field to another within the same row(s), this is how you would write the UPDATE (it's not as complex as you were making it out to be):

UPDATE `conflicts`
SET `fname` = COMPRESS(`fname`)
WHERE `conflict_id`=2;

According to http://dev.mysql.com/doc/mysql/en/string-functions.html, COMPRESS() wasn't added until 4.1.1 and the server must have been compiled with a compression library. Are you sure you are meeting both of those conditions in your environment?

hmmm. Ok, that works. I guess from your and Jigal's help, I take it that it is really only beneficial to use compress when you have a large text or blob field, need to save disk space and aren't going to be doing a search of that field.


Thanks Shawn & Jigal
Steve


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to