How to create a request that will display the first two lines of sports, it, etc. 
The conclusion specifically for this table on the screen should be as follows:
How to create a request that will display the first two lines of sports, it, etc. 
The conclusion specifically for this table on the screen should be as follows:
Suppose your table: id || text || news_category
Then:
select id, `news_category`, text from ( select id, `news_category`, text , (@num:=if(@group = `news_category`, @num +1, if(@group := `news_category`, 1, 1))) row_number from table1 t CROSS JOIN (select @num:=0, @group:=null) c order by `news_category`, id desc, text ) as x where x.row_number <= 2 Reply based on https://stackoverflow.com/questions/12113699/get-top-n-records-for-each-group-of-grouped-results
Source: https://ru.stackoverflow.com/questions/741127/
All Articles