Summary: I want to select all the profiles that have had issues in the past and have not yet been approved.
Here's what I have (this is as simple as it can possibly be)-
'Profile' Table
int ID
int CurrentEntryID
'Entry' Table
int ID
int ProfileID
int Approved
int Issues
Some example data-
Profile
ID=1, CurrentEntryID=10
ID=2, CurrentEntryID=20
Entry
ID=9, ProfileID=1, Issues=0
ID=10, ProfileID=1, Approved=0
ID=19, ProfileID=2, Issues=1
ID=20, ProfileID=2, Approved=0
Here's where the fun begins. I need to SELECT the profiles such that-
1) Entry.Issues > 0 for at least one Entry where Entry.ProfileID = Profile.ID
2) Profile.CurrentEntryID.Approved = 0
In English, I want to select all the profiles that have had issues in the past (Entry.Issues > 0) and have not been approved (by an admin) for current issues (CurrentEntry.Approved = 0).
I've done LEFT JOINs before, but never using the same table like this and I don't know how to branch it.