PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, October 28, 2022

[FIXED] How to count in LEFT JOIN table

 October 28, 2022     left-join, mariadb, sql-null, where-clause     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing