I'm having trouble creating a select query that will retrieve all user IDs that are not in the games, and availability between dates.
Example. Retrieve all users who are not between dates 2017-08-10
and 2017-08-12
.
Get [3 , 4, 5]
Users
| Id | Name |
| 1 | Jonh |
| 2 | Mark |
| 3 | Caroline |
| 4 | David |
| 5 | George |
Games
| Id | User_Id | Start_Date | End_Date |
| 1 | 1 | 2017-06-01 | 2017-06-01 |
| 2 | 1 | 2017-08-12 | 2017-08-13 |
| 3 | 4 | 2017-08-13 | 2017-08-14 |
Availability
| Id | User_Id | Start_Date | End_Date |
| 1 | 1 | 2017-05-01 | 2017-05-25 |
| 1 | 2 | 2017-08-10 | 2017-08-17 |
| 1 | 3 | 2017-06-20 | 2017-07-10 |
I am using Laravel 5.4, but I will be glad if the answer is Raw or Eloquent.
source
share