I’ve had a look around and I have found a few questions like mine but they lack an explanation.
I’m trying to search a table with multiple columns. I want to have the rows with the highest number of match columns at the top and the ones with the least at the bottom. I’ve seen a few ways of doing. My current and awful way is with lots of MySQLs querys and PHP doing the work.
Example
+----+-----------+----------+------+-------+
| ID | firstName | lastName | more | stuff |
+----+-----------+----------+------+-------+
| 1 | Bob | Hope | 1 | 450 |
| 2 | Steve | Hope | 0 | 29 |
| 3 | Gary | Flops | 1 | 8 |
+----+-----------+----------+------+-------+
I want to be able to search for lastName = Hope OR more = 1
I would like Bob Hope to be at the top because he matches two of the requested things. I know in this example this is what will happen but this is just an example.
If I query; lastName = Hope OR firstName = Steve. Steve should be at the top followed by Bob
I hope this is easy to understand.
Can some give me a detailed example with explanation.
How about this:
Result: