Search sort by parameter match count in the query? PostgreSQL
- by Ben Dauphinee
I am working on a search query in PostgreSQL, and one of the things I do is sort my query results by the number of parameters matched. I have no clue how this can be done. Does anyone have a suggestion or solution?
Table
brand color type engine
Ford Blue 4-door V8
Maserati Blue 2-door V12
Saturn Green 4-door V8
GM Yellow 1-door V4
Current Query
SELECT brand FROM table WHERE color = 'Blue' or type = '4-door' or engine = 'V8'
Result Should Be
Ford (3 match)
Saturn (2 match)
Maserati (1 match)