S.S
S.S

Reputation: 101

SQL - Query Problems using join

Below are my queries, query 1 works fine. enter image description here

But query 2 gives null, the only difference is that i am trying to compare the time on line 4. The begin time is 14:00:00 and end is 14:10:00, so it should give me a value.

In the tutorial table there can be many tutorials with the same room number and time, there is no date i handle that in the marks table.

Could i be using the wrong join type? or do i need to use union.

Upvotes: 1

Views: 40

Answers (2)

David Lee
David Lee

Reputation: 2100

Begin time of 14:00 and end at 14:10 does not meet the criteria.

Try the following: tutorial.begin >= '14:00:00' AND tutorial.finish <= '14:10:00'

Edit: Changed answer after reading over question again

Upvotes: 1

SqlZim
SqlZim

Reputation: 38063

try this instead

and '14:05:00' >= tutorial.begin
and '14:05:00' <= tutorial.finish

Your existing where only matches when tutorial.begin and tutorial.finish both = '14:05:00'.

Upvotes: 1

Related Questions