2015-04-02 67 views
0

我正在使用SQLite来存储我的数据。我想知道是否有一个比较类似于这样的方式:比较SQLite中的子字符串

Table Persons 
    ----------- 
     Name  |  "12 34 42" 

所以我想只比较字符串34。使用LIKE,通配符,substr(X,Y)instr(X,Y)总是返回该行,但我不希望出现这种情况:

select * from persons where substr('4', 1) > 0; 

select * from persons where instr(name, '4') > 0; 

有没有办法只能比较SQLite的一个子?

回答

1

做到这一点的典型方法是使用like

where ' ' || name || ' ' like '% 34 %' 
+0

它的工作原理。谢谢。 – 2015-04-02 07:20:33