In a MySQL database, I am attempting to find the most similar row across a number of numerical attributes. This problem is similar to this question but includes a flexible number of comparisons and a join table.
Database
The database consists of two tables. The first table, users, is what I'm trying to compare.
id | self_ranking
----------------------------------
1 | 9
2 | 3
3 | 2
The second table is a series of scores which the user gave to particular items.
id | user_id | item_id | score
----------------------------------
1 | 1 | 1 | 4
2 | 1 | 2 | 5
3 | 1 | 3 | 8
4 | 1 | 4 | 3
Task
I want to find the "most similar" user to a given one, valui