mike
mike

Reputation: 2780

SQL Like question

Is there a way to reverse the SQL Like operator so it searches a field backwards? For example, I have a value in a field that looks like this "Xbox 360 Video Game". If I write a query like below, it returns the result fine.

SELECT id FROM table WHERE title like "%Xbox%Game%"

However, when I search like this, it doesn't find any results.

SELECT id FROM table WHERE title like "%Video%Xbox%"

I need it to match in any direction. How can I get around this?

Upvotes: 2

Views: 286

Answers (2)

maček
maček

Reputation: 77816

Another option

SELECT id FROM table WHERE title RLIKE "(Xbox|Video)"

Upvotes: 5

SqlACID
SqlACID

Reputation: 4014

How about:

SELECT id FROM table WHERE title like "%Video%" and title like "%Xbox%"

Upvotes: 7

Related Questions