How to get the accumulated data that satisfies a certain value from the database

for example:

< table > < thead > < tr > < th > id < / th > < th > num < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > 1 < / td > < / tr > < tr > < td > 2 < / td > < td > 20 < / td > < / tr > < tr > < td > 3 < / td > < td > 30 < / td > < / tr > < tr > < td > 4 < / td > < td > 40 < / td > < / tr > < / tbody > < / table >

get the ID of num accumulating no more than N or more than 1 piece of data

for example, if you need 1"20"30 to take out ID:1,2,3
Never51, then it happens to be 1, 2, 3, and 3 to take out

, if you need 1"20"30 to take it out, and there is still room to take it out

.
Mar.20,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b335d0-2b6dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b335d0-2b6dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?