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?
The substr() function extracts and returns a substring from string . The position of the substring is determined by index and its length is determined by count . If any parameter is NULL, a NULL will be returned. Otherwise, if string is not a BLOB it will be assumed to be a text value.
SQLite substr() returns the specified number of characters from a particular position of a given string. A string from which a substring is to be returned. An integer indicating a string position within the string X. An integer indicating a number of characters to be returned.
The TRUNCATE TABLE statement is used to remove all records from a table. SQLite does not have an explicit TRUNCATE TABLE command like other databases. Instead, it has added a TRUNCATE optimizer to the DELETE statement. To truncate a table in SQLite, you just need to execute a DELETE statement without a WHERE clause.
SQL Server TRIM() Function The TRIM() function removes the space character OR other specified characters from the start or end of a string. By default, the TRIM() function removes leading and trailing spaces from a string. Note: Also look at the LTRIM() and RTRIM() functions.
@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) %';
... noting that strings are indexed from 1 in SQLite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With