将空格替换为“-”&将大写替换为小写

6tdlim6h  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(386)

我有两个不同的领域 name & slug
我想做的是举个例子 row #18 我有 name 的价值 Full Process Microbiological Analysis 并抄送至 slugs 这样地 full-process-microbiological-analysis 现在我可以像这样复制值

UPDATE services
 SET slug = name
 WHERE slug IS NULL OR slug = ""

但它只复制值,不将大写改为小写,将空格改为破折号(-)

mmvthczy

mmvthczy1#

试试这个:

update services set
slug = replace(lower(name), ' ', '-')
where slug is null or slug = ''

观看现场演示:

select replace(lower('Full Process Microbiological Analysis'), ' ', '-')

退货

full-process-microbiological-analysis

相关问题