I hope the answer is simple and I'm silly.
So I've two tables: day
(with PK id_day
) and hour
(with PK id_hour
).
I've an another table tilt_time
which has id_day
, id_hour
fields and a plus FK field (which has prohibited times). E.g. tilt_time
has the following rows (id_day
, id_hour
, id_target
):
1,1,1
1,2,1
1,3,1
1,1,2
1,2,2
In table day
id_day
is between 1 and 5 (monday to friday) and hour
id_hour
is between 1 and 6 (so you can imagine a day_hour
table with 5*6=30 values).
So I want query id_target=1
's free periods and id_target=2
's free periods (everbody's free periods). So I want similar:
1,4,1
1,5,1
1,6,1
2,*,1
3,*,1
4,*,1
5,*,1
// id_target=2
1,3,2
1,4,2
1,5,2
1,6,2
2,*,2
3,*,2
4,*,2
5,*,2
(* means all valid id_hour
values, so every line with * represents 6 different lines)
How can I do this query?