I have tried to implement the ideas from this post to order my output by the occurrences of each pair -
MySQL: Count occurrences of distinct values
What I need is to be able to take into consideration two different columns, not just "name". So what would be the most efficient way to order the output of the following table -
id name food
----- ------ ------
1 Mark apple
2 Mike pear
3 Paul apple
4 Mike pear
5 Mike banana
6 John apple
7 Mark pear
The expected order should be:
name food count
----- ------ -----
Mike pear 2
Mike banana 1
Mark apple 1
Mark pear 1
Paul apple 1
John apple 1