I’d like to convert this problem into a query.
At a guess should be three leftjoin and two select
exercises
+-----+---------+
| id | require |
+-----+---------+
| 1 | |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | |
| 6 | 5 |
| 7 | |
+-----+---------+
done
+-----+
| id |
+-----+
| 1 |
| 2 |
+-----+
Having done the exercises one and two, which exercises can I do now?
Solution: 3,5,7
My logical process, step by step:
(all) – SELECT(required – done)-(done)
(1,2,3,4,5,6,7) – SELECT((1,2,3,5)-(1,2)) – (1,2)
(1,2,3,4,5,6,7) – SELECT(3,5) – (1,2)
(1,2,3,4,5,6,7) -(4,6) – (1,2)
(3,5,7)
How to write the query?
Another solution without subselect
the
WHEREcan be semplified (distributivity)