How to search for a substring in SQLite?

前端 未结 3 893
暖寄归人
暖寄归人 2021-02-05 01:13

Whats the most efficient way to search for a sub string in SQLite?

I\'m looking at the LIKE operator.

Do I have the right idea? Has this worked well for you?

3条回答
  •  耶瑟儿~
    2021-02-05 01:29

    Years have passed since the question was asked and answered and in 2012 SQLite version 3.7.15 introduced a function instr( string, substring) - returns the location of a substring in a string, 0 if not found. (https://www.techonthenet.com/sqlite/functions/instr.php)

    sqlite> SELECT instr('TechOnTheNet.com', 'T');
    Result: 1

    I have not benchmarked against LIKE, but IMHO could be faster.

提交回复
热议问题