greetings im working on some inventory control and looking for the way to perform this action ...
i have 50 avaialble seats for training on my given days..
in my database when someone takes a spot on a given day the program rus this query
Insert into trainingdates (userID, roomId, DateId,SeatsId)
so when a manager is setting training for thier employees they have a dropdown menu to select the room, the date, how many seats they need
What i want to do is query Trainingdates table and count every instance where
the same room and date match from their dropdowns (giving me the total number of instances) .. so that lets say there are already 20 slots taken
I can takethe numbe from this query subtract it from 50 - 20 = 30 and compare it the number of seats requested.. If the user wanted 30 or less they can still keep that choice.. of not they cant beucause thats overselling
If it is the latter, you would do
select count(userID)
from trainingdates
where roomId = <selected room id>
and dateid = <selected date>
If it is the former, you would do
select sum(seatsid)
from trainingdates
where roomId = <selected room id>
and dateid = <selected date>