sql - Most efficient way to get lists? -
What is the best way to get a list of things?
I have two tables:
I want to get the list of object A, B with Subject B, but in the top five of B.
Suppose there are people, and B is the type of food, with sort_key, how much a person likes food. How do I get each person (or some people) and their top five meals?
On the previous comment, if it is an INT in which you can not enter non-numeric.
Assume the following data:
a - id 1 2 3b ------- -------------- --- ID Support sort_key 1 1 1 2 1 2 3 2 1 4 3 1 5 1 3 6 1 4 7 1 5 8 1 6 9 2 2 10 2 3
The following in MySQL The query will tell you:
SELECT a. *, (As a SELECT GROUP_CONCAT (id) AS as a result from ASBC by BI WHERE BI .id = a.id command by sort_key LIMIT 5) a
:
id id 1 1,2,5,6, 7,8 2 3 9, 10 3 4
Comments
Post a Comment