Reputation: 17383
suppose I have a table name : TEST, that it has 2 columns ID and CONTENT, like this :
TEST TABLE :
ID ======= CONTENT
0 ======= hello world
now, how can I split CONTENT column from 0 index to 5 index to retrieve just hello word? (at here, ID=> 0) (I just want to use sql, not other functions in others languages );
Upvotes: 0
Views: 2944
Reputation: 61
The
substr(X,Y,Z)
function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted thensubstr(X,Y)
returns all characters.
The answer to your question is:
select substr(content, 0, 5) from test where id >= 0;
Upvotes: 1
Reputation: 69198
Check substr()
function in sqlite3 core functions. It will let achieve what you need.
Use it as:
SELECT substr(content, 0, 5) FROM test WHERE id >= 0;
Upvotes: 0