0

I have a table I am trying to connect to to give me a name (however this name table has multiply entries for a name).

StaffName dateFrom dateTo
JIAO-L 2023-03-17 NULL
JIAO-M 2017-07-25 2023-03-16

I want to being back the name based on on date of 3/4/23, however when I try various joins they are coming up as null.

I have tried this code in many formats changing the

SELECT e.eventdate
     , e.StaffCode
     , sn.
FROM      Events e
LEFT JOIN StaffName Sn 
       ON e.StaffCode = sn.StaffCode
      AND e.eventdate !> sn.dateto
      AND e.eventdate !< sn.datefrom
lemon
  • 14,875
  • 6
  • 18
  • 38
  • 1
    You need to make some more clarity in your description. It's not clear what you're looking after from it, and an expected output (in addition to the improved description) would help in that regard. – lemon Jun 01 '23 at 09:50
  • I assume the table given in your question is meant to be the table StaffName given in your code? If so, then where is the StaffCode column that you are using in your SQL? Also, it tends to make these types of queries easier if you make the end date something in the far future, such as 2999-12-31, rather than having it as null – NickW Jun 01 '23 at 13:36

0 Answers0