S
S
Setti2010-09-20 21:01:54
MySQL
Setti, 2010-09-20 21:01:54

A selection of top rubrics and a certain number of top titles for each of the rubrics at once

Dear colleagues!
I've been thinking about this for a few days now.
There is a table with headings and a table with titles. Each category and title has a rating field.
I make a selection of titles with their headings.
The task is to choose the TOP 3 titles from the TOP 3 headings. In other words, I want the result to be something like this:

movies | avatar | rubric rating 10 | title rating 100 |
movies | godfather | rubric rating 10 | title rating 90 |
movies | star wars | rubric rating 10 | title rating 60 |
serials | house doctor | rubric rating 8 | name rating 200 |
serials | tbv | rubric rating 8 | title rating 40 |
serials | interns | rubric rating 8 | title rating 10 |
cartoons | there lived a dog | rubric rating 5 | title rating 90 |
cartoons | tom and jerry | rubric rating 5 | name rating 80 |
cartoons | burum was overthrown from the throne | rubric rating 5 | title rating 66 |

In production, of course, there are more entities, but the essence is revealed.
Is there a nice solution?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Anton, 2010-09-20
@Setti

This is not your case - habrahabr.ru/qa/437/ ?

P
Progrik, 2010-09-20
@Progrik

As far as I understand, I want to do it all in one request?
Please indicate the names of the tables (it is possible conditionally) and the main dependencies (ie, if the rating is in another table, then by which identification field does it determine its name).

P
phasma, 2010-09-20
@phasma

do DESCRIBE `name of tables`;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question