Reputation: 431
I've got a table full of substrings, and I need to select all substrings, which are in the search string.
Basically it would be the mirrored form of a where-condition:
WHERE "SearchString" LIKE "%"+ currentColumnValue +"%"
I know, that this is not possible, but for performance reasons I don't want to iterate every single database entry.
Maybe you have got an idea how to solve this kind of problem?
Upvotes: 0
Views: 119
Reputation: 1574
You can try this
$value = //your value
' select * from tb_name where col_name like %".$value."% '
Upvotes: 0
Reputation: 40061
You can do
where 'SearchString' like concat('%', columnValue, '%');
This will be very slow as it would do a table scan and a like-compare on each line, but the result is correct.
http://sqlfiddle.com/#!2/e2b066/1
Upvotes: 3