开发者

Using Sqlite3, create a slug version of a full title

开发者 https://www.devze.com 2023-02-09 21:13 出处:网络
I have a sqlite3 database table.I added a column called title_slug.I want to开发者_如何学Go take the contents of title column, and update the new title_slug column with a slug version.Can I do this st

I have a sqlite3 database table. I added a column called title_slug. I want to开发者_如何学Go take the contents of title column, and update the new title_slug column with a slug version. Can I do this straight from sqlite3 or do I have to code it outside of the program?


first of, there are no loops in SQLite. A not very generic solution could be:

UPDATE mytab SET title_slug = replace(replace(title_slug, ' ', '-'), '!', '')

but you would have to add many chars to replace ?!

0

精彩评论

暂无评论...
验证码 换一张
取 消