return only joined results is the results are not joined more than x times
Posted on 2011-10-27
Hi there experts,
I have two tables: table 1 with names and table 2 with dates and times
columns in table 1:
id, firstname, lastname, appointment
columns in table 2:
id, date, time, number
column 'appointment' contains the id's of colums 2. I can now plan an appointment for a certain person.
The number of persons on a single appointments is limited. Therefore I added the column 'number' which contains an integer value representing the maximum number of persons.
In my form I would now like to filter the appointments that are not fully booked yet.
I want to show the table 2 id's where the count of table 1 appointment values is less than the maximum number of persons for that specific date/time