SQLite中的向后匹配

时间:2010-11-12 09:32:37

标签: firefox sqlite

我需要在SQLite中编写后向匹配查询。有没有办法做到这一点?

我的例子如下:

SELECT * FROM urls where  forwordurl LIKE '%www.google.com%'

工作正常,但我需要如下所示

SELECT * FROM urls where  'www.google.com' LIKE %forwordurl%

有什么办法吗?

1 个答案:

答案 0 :(得分:4)

这有效:

SELECT * FROM urls WHERE 'www.google.com' LIKE '%' || forwordurl || '%'

示例:

[C:\Temp] :sqlite3 test.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table urls (forwordurl text);
sqlite> insert into urls (forwordurl) values ('google');
sqlite> select * from urls where 'www.google.com' like '%' || forwordurl || '%';
google
sqlite> ^Z