If in the while loop i mark these 10 rows as “SENT”,
then everytime the NEXT 10 rows will be selected or i have to do some programming to again select the next 10 rows ??
Let’s start with the minimum code changes to get OP’s code working.
Vinpkl, first time through your outer while loop, you fetch a row, then with that one row, your inner loop runs 10 times and prints the same id of the same row over and over, so we get rid of the inner loop.
That being said, it’s better to do the limiting part directly in SQL, just like Dormilich suggested. It shouldn’t matter whether you’re running this as a cron job.