I have 2 tables.
Table1 contains 4 columns (Id, pt_RFID, sessionTime, sessionDate)
Table2 contains 7 columns (Id, pt_RFID, sessionTime, sessionDate, isTrainerShow, isTraineeShow)
Now, what I would like to achieve is to retrieve the sessionTime from Table1 where Table1.pt_RFID =@pt_RFID, Table2.sessionTime IS NULL and Table1.sessionDate = FORMAT (getdate(), 'yyyy-MM-dd').
The problem is, it did not give me the data that I wanted. Below is my actual Table:
Table1
Table2
Below is my query that obviously is not correct:
- select
- st.sessionTime
- from dbo.tblPT_SessionTime st
- LEFT JOIN dbo.tblPT_Sessions sd ON sd.sessionTime = st.Id
-
- WHERE sd.sessionTime IS NULL and st.pt_RFID = @pt_RFID AND st.sessionDate = FORMAT (getdate(), 'yyyy-MM-dd')
Below is the result of the above query and should give me 15 rows since the sessionDate of the 1st row from Table2 is not the current date.
I hope someone could assist me.