Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 mysql 数据库列,其中包含用逗号分隔的字符串值(例如:)apple, pear, orange, banana, grape。我需要创建一个 SQL 语句,它将在每个字符串值的任一侧插入一个 * (例如:)*apple*,*pear*,*orange*,*banana*,*grape*。我知道如何获取这些值并解析它们,但不确定如何添加 * 字符。任何建议,将不胜感激。
apple, pear, orange, banana, grape
*apple*,*pear*,*orange*,*banana*,*grape*
UPDATE the_table SET the_column = CONCAT('*', REPLACE(the_column, ', ', '*,*'), '*')