如何将数据库列与字符串匹配

时间:2021-11-17 18:28:45

For example, I have a table like this:

例如,我有一个这样的表:

id |      name      |
--------------------
1  | T              |
2  | Text           |
3  | A              |
4  | Text1 and Text |
5  | Txt            |

, and I want to reverse match column with string, something like this:

,我想用字符串反转匹配列,如下所示:

select * from table_name where %name% like 'Text1 and Text2 and Text3' 

, and to get these results:

,并获得这些结果:

id | name |
-----------
1  | T | 
2  | Text |
4  | Text1 and Text |

How is that posible?

这怎么可能?

1 个解决方案

#1


3  

Try:

SELECT *
FROM table_name
WHERE 'Text1 and Text2 and Text3' LIKE '%'||name||'%'

UPD Here is my SQLFiddle with example: SQLFiddle.

UPD这是我的SQLFiddle示例:SQLFiddle。

#1


3  

Try:

SELECT *
FROM table_name
WHERE 'Text1 and Text2 and Text3' LIKE '%'||name||'%'

UPD Here is my SQLFiddle with example: SQLFiddle.

UPD这是我的SQLFiddle示例:SQLFiddle。