Jump to content

LEFT JOINs not joining...


dtyson2000

Recommended Posts

Hello all.

 

I have this query:

 

SELECT userid, namelast, namefirst, userpaid
(SELECT COUNT(*) 
   FROM login 
   WHERE YEARWEEK(logindate) = YEARWEEK(CURDATE()) 
   AND login.luserid = users.userid) 
   AS wklogins, 
(SELECT COUNT(*) 
   FROM login 
   WHERE YEAR(logindate) = YEAR(CURDATE()) AND MONTH(logindate) = MONTH(CURDATE()) 
   AND login.luserid = users.userid) 
   AS mologins 
FROM users 
LEFT OUTER JOIN login ON users.userid = login.luserid AND !(login.logindate < CURDATE()) 
LEFT OUTER JOIN payments ON users.userid = payments.puserid 
WHERE ((DATE(login.logindate) != CURDATE()) || login.luserid IS NULL) && (users.userpaid = 'T') 
ORDER BY users.namelast, users.namefirst

 

For some reason, which I can't seem to find, the joins don't seem to be happening. I definitely know that I'm getting the desired results from the primary and subqueries but I am not seeing anything joined to the resulting dataset. Do you see something wrong with this query? If you do, can you point me in the direction I need to go to fixing it? Thank you, in advance, for your help!

Link to comment
https://forums.phpfreaks.com/topic/273398-left-joins-not-joining/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.