I have a table called students
and a table called documents
. Each student can have any amount of document entries in the documents
table, but might also have no document entries. Some of the documents might've been approved, others not.
table 1: students
, table 2 documents
. student
PK is user_id
and document
PK is document_id
, and document
table has user_id
in it as well. document
table has column approved
which can contain either a Yes or a No. So these two tables are linked by user_id
How can I write a MySQL query (or even better, in Active Record style for Code Igniter) that can list all students that have at least 1 unapproved document?