Friday, October 28, 2022

[FIXED] How to count in LEFT JOIN table

Issue

I need to get only NULL values in checktime or pin columns

enter image description here

My SQL query

SELECT emp.`emp_id`,cio.`pin`,cio.`checktime` FROM payroll.employees AS emp 

    LEFT JOIN (SELECT * FROM zkteco_biotime.checkinout WHERE checktime > "2022-09-20 23:59:59") AS cio ON emp.emp_id = cio.pin

    WHERE emp.status=0 GROUP BY emp_id ORDER BY checktime DESC

when i use AND cio.checktime=NULL after emp.status=0 it showing me result blank


Solution

You should use

AND cio.checktime IS NULL

Null compared with anything will result in FALSE. Only "IS NULL" and "IS NOT NULL" may return TRUE.



Answered By - arheops
Answer Checked By - Robin (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.