SQL SELECT: "Give me all documents where all of the documents procedures are 'work in progress'"
- by prestonmarshall
This one really has me stumped. I have a documents table which hold info about the documents, and a procedures table, which is kind of like a revisions table for each document. What I need to do is write a select statement which gives me all of the documents where all of the procedures have the status "work_in_progress". Here's an example
procedures table:
document_id | status
1 | 'wip'
1 | 'wip'
1 | 'wip'
1 | 'approved'
2 | 'wip'
2 | 'wip'
2 | 'wip'
Here, I would want my query to only return document id 2, because all of its statuses are work_in_progress. I DO NOT want document_id 1 since one of its statuses is 'approved'. I believe this is relational division I want, but I'm not sure where to start. This is MySQL 5.0 FYI.