Tables bugs and dependencies looks like this:
select * from bugs;
+--------+--------+
| bug_id | status |
+--------+--------+
| 20 | NEW |
| 45 | CLOSED |
| 47 | NEW |
| 30 | NEW |
| 50 | CLOSED |
+--------+--------+
select * from dependencies;
+-----------+---------+
| dependson | blocked |
+-----------+---------+
| 20 | 45 |
| 20 | 47 |
| 30 | 50 |
+-----------+---------+
Expected result of join query: 30
What? Extract only 30 from column dependson, table dependencies because 30 is the only ( NEW status ) one which blocks ( col: blocked-50 ) a bug whose status is CLOSED.
Although the dependson entry 20 is blocking 45 which is CLOSED but it also blocks 47 which is not CLOSED.
Note: Both the columns dependson and blocked are foreign key of bug_id.
I tried different queries but not able to get proper one still… Can anybody please help ?
Update: need status only NEW not all.
Try this query –