I want to find the 3rd available appointment from a list of appointments.
MySql database has rows with RotaType, Date and UnusedSlots as columns
I want to do something like
$sql3 = "SELECT * FROM `UsageDailyUnusedSlots` WHERE Date >= '$Today' AND RotaType LIKE '%Derm%' AND UnusedSlots > 0 AND RotaType NOT LIKE '%- Y%' AND RotaType NOT LIKE '%- y%' ORDER BY Date LIMIT 1 OFFSET 2;";
however this would find me the 3rd day with available slots, not the 3rd slot.
I could do a complicated loop of each row, adding up the value with each iteration/loop and echoing the value when the total >= 3, however I feel there must be a better way.
Here is a scenario
My sql code above would select 31/01/2020 as the 3rd day with UnusedSlots on, however I want it to select 30/01/2020 as the date as that's when the 3rd next unused appointment is
Any thoughts?
Thanks