I need a way to get the best match of some conditions in WHERE clause.
The WHERE clause has about 8 different conditions and from the rows, I want to get the results GROUPED BY only those which are BEST MATCH for the given condition.
For example, look at the table below:
And I give query like :
SELECT * from users WHERE age < 25 OR marks > 190
and this SHOULD show:
Row: 1 and 2 as the ages are < 25 and marks are > 190. However it MUST not show Row 4, because YES the age is < 25 but marks is NOT > 190.
I know that I can do it by using "AND" instead of "OR" but in my table there are about 30 columns and I must use "OR" to get the results. Only thing is that I want the BEST POSSIBLE ROWs that matches most of the conditions in the where clause.
Please help !