Bit of a complicated SQL question here.
I currently have a SELECT statement which matches several fields, like this.
SELECT field1, field2, field3, field4, field5
FROM table
WHERE field1 = 'variable 1'
AND field2 = 'variable 2'
AND field3 = 'variable 3'
AND field4 = 'variable 4'
AND field5 = 'variable 5'
I would like to modify the statement so that it uses OR's instead of AND's so that it selects all records which match any of the fields.
The next step is to rank the results using a scoring system.
If field 1 was matched then 1000 is added to the score
If field 2 was matched then 800 is added to the score
If field 3 was matched then 600 is added to the score
If field 4 was matched then 10 is added to the score
If field 5 was matched then 1 is added to the score
So...
Match 1 - If field2 and field 3 match then the score would be 1400
Match 2 - If field1 and field 4 match then the score would be 1010
Match 1 would be at the top of the results.
Any help with some SQL to achieve this would really be appreciated.