A slightly confusing title. I will explain by example.

I have 2 tables - articles and headings. I have a set of id headings. I need one request to get the last 5 articles in each category from the list. MySQL database.

I couldn't think of anything else except how to use UNION .

 SELECT * FROM article WHERE category_id = :id1 ORDER BY date_create DESC LIMIT 0, 5 UNION -- ... 

Is this me stupid or is there really no other way?

  • Ways something dohrena. But the one you used is one of the most effective (in the sense - for MySQL). - Akina
  • one
    For example, sql-ex.ru/help/select16.php - msi
  • @msi is what you need. The request is scary, but much faster than UNION. Thank you)) - ghost404

0