I have three tables
t1
--------------
userID
userEmail
userName
userType
t2
--------------
businessID
businessUserID
t3
--------------
recordID
recordBusinessID
action (ENUM: pending, open, closed)
I need to retrieve records if results found in t3 ONLY has records with with action = 'pending'.
SELECT
t2.businessID,
t1.userEmail,
t1.userName
FROM t2
LEFT JOIN t1 ON (t1.userID = t2.businessUserID)
LEFT JOIN t3 ON (t3.recordBusinessID = t2.businessUserID)
WHERE userType = 'active'
AND t3.action = 'pending'
t3.action != 'open'
t3.action != 'closed'
It seems like I should be getting results, because my current t3 is empty, but I don't. What am I missing?
t3 can have results but I only need to match if t3.action is nothing but 'pending'.
Aucun commentaire:
Enregistrer un commentaire