I have a table 'MyTable' which has some business logics. This table has a column called Expression which has a string built using other columns. My query is
Select Value from MyTable where @Parameters_Built like Expression
The variable @Parameters_Built is built from Input parameters by Concatenating all together.
In my current scenario,
@Parameteres_Built='1|2|Computer IT/Game Design & Dev (BS)|0|1011A|1|0|'
Below are the expressions
---------------------
%%|%%|%%|0|%%|%%|0|
---------------------
1|2|%%|0|%%|%%|0|
---------------------
1|%%|%%|0|%%|%%|0|
---------------------
So my above query returns true for all the three rows. But It should return only the second row (Maximum match).
I just don't need a solution with fix for this scenario. It's just a example. I need a solution like choosing the best match. Any idea?