2012-12-07 22 views
2

匹配,例如,我有这样的一个表:如何数据库列用绳子

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

,我想逆转与字符串匹配列,这样的事情:

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

,并得到这些结果:

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

这是可行的吗?

回答

3

尝试:

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

UPD这是我SQLFiddle与例如:SQLFiddle