How do you put a few requests in one?



  • There are about 40 categories on the website, and they're like this:

    <li>Комедии<sup>137</sup></li>
    

    137 is the number of films in this category. But since the categories are 40, making 40 queries at every page update doesn't sound very good.

    I think it might be a one-on-one request or better? And if it's better to be one of the things right?

    SELECT COUNT(cat) FROM film WHERE cat = 'comedy'
    

    These are 40 requests per person.



  • Here's the request. For name There must be your field called:

    SELECT `name`, `cat`, COUNT(`cat`) FROM `film` GROUP BY `cat`;
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2