How to get substring in SQLIte?

后端 未结 3 747
孤城傲影
孤城傲影 2020-12-14 13:59

I retrieve quite a lot of data from SQLite database. When retrieving I map it to different views in my application. There is a text field in my table from which I don\'t wan

3条回答
  •  旧巷少年郎
    2020-12-14 14:46

    To get the substring in SQLite

    You can use the builtin function in SQLite which is substr(X,Y,Z). The x field represents the string input to be sliced, the y and z field represents the starting point and ending point respectively using an index.

    ===============================
    |Database Table : **articles**|
    ===============================
    |id | description             |
    -------------------------------
    |29 | Lorem ipsum domit       |
    ===============================
    

    Now we will try to make a select query for our description

    SELECT substr(description,1,4) FROM articles where id='29';
    

    Output would be: Lore instead of Lorem ipsum domit

提交回复
热议问题