Jump to content

Recommended Posts

I am running this query

SELECT `subordinate`

FROM `people`

LEFT JOIN `hierarchy` ON `people`.`id` = `manager`

LEFT JOIN `absence` ON `person_id` = `subordinate`

WHERE `people`.`id` = 'xxx' AND NOT (NOW() > `start`

AND NOW() < `finish`)

to establish whether the subordinate is in the office today. 

 

Tables are:

  • people - person specific data
  • hierarchy - which has the relationships between manager and subordinate
  • absence - start and finish dates of absences

 

It works fine if there is at least one entry for the subordinate in the absence table, returning the id of only those available.  But it does not return people if they are not in the absence table at all.  The work around is a dummy entry as each user is created, but to me this seems inelegant when it must be possible to modify the query so it also returns values where `subordinate` has no entry at all.

 

Your help would be much appreciated.  I have tried endless permutations of AND NOT OR NULL etc and I just know it is in there somewhere but cannot get my head around it...

Link to comment
https://forums.phpfreaks.com/topic/138052-catching-null-values/
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.