1

For MySQL, is it possible to update a field of type SET using one of the field's named values and bitwise operators? Example:

Assume foo to be SET('a', 'b',...), then the following does not work:

UPDATE mytable SET foo = foo | 'a' WHERE ...

Apparently, only foo = 'a' or foo = foo | 1 work. Is there any trick to get the above example working and make MySQL be aware of 'a' being not a "normal" string? I'd like to avoid magic numbers... Many thanks!

4

1 回答 1

2
UPDATE mytable SET foo = CONCAT_WS(',', foo, 'a') WHERE ...
于 2013-06-13T14:28:52.457 回答