I am trying to sort a user table based on how many comments they linked to them in the secondary comment table. I figured sub-selection would be the best tool, but I can't get the syntax correctly.
Test data table for users:
id | user_id
1 | 1000
2 | 1001
3 | 1002
Testdata table comment table p>
id | link_id
1 | 1002
2 | 1000
3 | 1002
4 | 1000
5 | 1002
6 | 1001
7 | 1000
8 | 1002
The expected sorted result in the first table:
id | user_id
3 | 1002
1 | 1000
2 | 1001
Any push in the right direction would be extremely helpful, thanks! =)
moodh source
share