Reputation:
Currently I have a query like this:
"SELECT * FROM Table1 WHERE col1 LIKE '%fox jumped over%' "
This will find a result if col1
has a value of the fox jumped over the dog
. How Could I modify this query so it would also find a match for "jumped over".
I need a query that checks for LIKE
both ways, if that makes sense.
I do not know the value of col1, therefore I can not have a condition like "%jumped over%"
. I can only work with the value parsed.
I'm currently building the query and then parsing it into a custom pdo function.
Upvotes: 0
Views: 65
Reputation: 24703
I think a lot of people have misunderstood what you need. If I understand you correctly you need the following query:
SELECT * FROM Table1
WHERE col1 LIKE '%fox jumped over%' OR 'fox jumped over' LIKE CONCAT('%', col1, '%')
Upvotes: 2
Reputation: 141
You can get the desired output by using below query -
SELECT * FROM Table1 WHERE col1 LIKE '%fox jumped over%'" OR
col1 LIKE '%jumped over%'
Upvotes: 0