Bug #117019 Add SET datatype functions SET_ADD(), SET_REMOVE(), SET_REPLACE()
Submitted: 19 Dec 2024 0:57 Modified: 19 Dec 2024 11:38
Reporter: David Berky Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Types Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: SET datatype

[19 Dec 2024 0:57] David Berky
Description:
Using the SET datatype would be much easier if there were functions to:

SET_ADD(field_name, value) - ignore if already in set
SET_REMOVE(field_name, value) - ignore if not in set
SET_REPLACE(field_name, replace_value, with_value) - ignore if replace_value is not in set

Examples:
UPDATE `mytable` SET `myfield`=SET_ADD(`myfield`,'new_value') WHERE `id`=1;
UPDATE `mytable` SET `myfield`=SET_REMOVE(`myfield`,'new_value') WHERE `id`=1;
UPDATE `mytable` SET `myfield`=SET_REPLACE(`myfield`,'old_value','new_value') WHERE `id`=1;

How to repeat:
Feature request
[19 Dec 2024 2:10] Tsubasa Tanaka
What you need are sys.list_add and sys.list_drop ?

https://dev.mysql.com/doc/refman/8.0/en/sys-list-add.html
https://dev.mysql.com/doc/refman/8.0/en/sys-list-drop.html
[19 Dec 2024 11:38] MySQL Verification Team
Thank you Mr. Berky and Tanaka,

This is not a missing feature.

Those features already exist, but with a different syntax.

Closed.