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')
I hope someone could assist me.


Ronika JencyRank #770 · 3K reputationPosted Dec 9, 2019, 11:38 PM EST
Jes SieRank #1,285 · 1.3K reputationPosted Dec 10, 2019, 4:24 PM EST
Amit MohantyRank #112 · 20K reputationPosted Dec 10, 2019, 5:56 PM EST
Ashutosh GuptaRank #805 · 2.9K reputationPosted Dec 10, 2019, 6:30 PM EST