a_mark
a_mark

Reputation: 351

How to match database column with string

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?

Upvotes: 2

Views: 479

Answers (1)

Ihor Romanchenko
Ihor Romanchenko

Reputation: 28641

Try:

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

UPD Here is my SQLFiddle with example: SQLFiddle.

Upvotes: 3

Related Questions