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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.