Table Structure –
Table –TblRegister_master
ID
Name
Role
From
To
TotalSeats
Cost
Active
101
Abhijit
Driver
Bandra
CBD Belapur
3
100
1
102
Neha
Passenger
Powoi
Ghansoli
0
103
Pranav
Ghatkopar
5
500
104
Mohit
Thane
105
Riddhi
Vikroli
Belapur
1000
106
Mansi
Ghatkoper
107
Krunal
Airoli
108
Heta
109
Shruti
1500
110
Rohit
4
111
Selvi
Table – TblApplied
intDriverID
intPassengerID
Confirmation
N
2
Y
R
6
7
8
9
10
11
12
13
14
intDriverID – Foreign Key to table – TblRegister_master on Column ID and Role – Driver
intPassengerID – Foreign Key to table – TblRegister_master on Column ID and Role – Passenger
Confirmation –N – Pending From Driver, Y- Accepted, R-Rejected
I need the following –
1. E.g. For Driver “Abhijit”, ID – 101- He has total 3 seats with him. i.e. he can take 3 passengers.
Till now, 5 Passengers have sent him requests.
But, He has accepted only one request – 107 – of Krunal.
So, He has (3-1=2) seats empty.
Hence, while showing Total Rides of theDrivers, I need to show this Driver.
For Driver “Rohit”, ID – 101, He has 4 seats.
Total 5 Passengers requested his ride.
He accepted 4 and rejected 1.
So, since his seats are booked, he should not be displayed in the list.
Hence, I need theoutput as –
How to get this list ?