SQLite Replace () function executes a string replacement

I have a column in the sqlite database that I need to modify.

The column is an array of values, as shown below:

< p>

0.021460.04419,0.04551,0.02734,0.011,0.005

The array lacks a comma between the first and second values, so the array should look like this:< /p>

0.02146,0.04419,0.04551,0.02734,0.011,0.005

The data value will never be greater than 0.9, so I am trying to build an update query, which will use The replace() function performs string replacement and recognizes the second “0” and replaces it with “,0.”, but I don’t know how to do it.

Just add a comma for all occurrences of 0:

replace(TheColumn, '0 .',',0.')

Then delete duplicates:

replace(replace(TheColumn, '0.',',0. '),',,',',')

and the beginning comma:

substr(replace(replace(TheColumn, '0.' ,',0.'),',,',','), 2)

I have a column in the sqlite database that I need to modify.

The column is an array of values, as shown below:

0.021460.04419,0.04551,0.02734,0.011,0.005

The array lacks a comma between the first and second values, so the array should look like this:

0.02146,0.04419,0.04551,0.02734,0.011,0.005

0.02146,0.04419,0.04551,0.02734,0.011,0.005

pre>

The data value will never be greater than 0.9, so I am trying to build an update query that will use the replace() function to perform string replacement, recognize the second "0". and replace it with ",0. ", but I don’t know what to do.

Simply add a comma to all occurrences of 0:

replace(TheColumn, '0.',',0.')

Then delete duplicates:

replace(replace(TheColumn, '0.',',0.'),',,',',')

and the comma at the beginning:

substr(replace(replace(TheColumn, '0.',',0.'),',,',', '), 2)

Leave a Comment

Your email address will not be published.