SQLite中的向后匹配(Backward matching in SQLite)

编程入门 行业动态 更新时间:2024-10-28 01:21:28
SQLite中的向后匹配(Backward matching in SQLite)

我需要在SQLite中编写后向匹配查询。 有什么办法吗?

我的例子如下:

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

这工作正常, 但我需要吼叫

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

有什么办法吗?

I need to write backward matching query in SQLite. Is there any way to do it?

My example is bellow:

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

that works fine, but i need to as bellow

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

Is there any way to do it?

最满意答案

这有效:

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

This works:

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

Example:

[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

更多推荐

本文发布于:2023-07-30 08:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQLite   matching

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!