如何从sqlite3数据库中的字符串中删除字符? [英] how to remove characters from a string in sqlite3 database?
本文介绍了如何从sqlite3数据库中的字符串中删除字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的字符串 a) 我的 sqlite 数据库中的文本..我想从数据库中删除 a) ..有人知道这个查询吗?
i have a string like this a) Text in my sqlite databse..i want to remove a) from databse..anyone know a query for this?
推荐答案
@laalto's answer is close,但它不适用于边缘情况,特别是如果 'a) '
出现在字符串的其他地方.您想使用 SUBSTR
仅删除前 3 个字符.
@laalto's answer is close, but it will not work on edge cases, specifically if 'a) '
occurs elsewhere in the string. You want to use SUBSTR
to only remove the first 3 characters.
sqlite> SELECT REPLACE ("a) I have some information (or data) in the file.", "a) ", "");
I have some information (or datin the file.
sqlite> SELECT SUBSTR ("a) I have some information (or data) in the file.", 4);
I have some information (or data) in the file.
所以更新他的查询,它应该变成:
So updating his query, it should turn into:
UPDATE tbl SET col=SUBSTR(col, 4) WHERE col LIKE 'a) %';
这篇关于如何从sqlite3数据库中的字符串中删除字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文