Scenario: Consider you have a Table Say Student with Column say Age.
Student--
Age
-----
1
2
3
3
4
5
6
5
Question: What will be the result of the following query? With reason
(Use of query analyzer is not permitted,just think and answer)
Declare @Number1 int=4 Declare @Number2 int=2 SELECT * FROM Student WHERE Age BETWEEN @Number1 and @Number2
it will return 0 records.
ReplyDeleteU r right Prodiuos, but you know why?
ReplyDeleteThe BETWEEN operator logically works as "x>=y AND x<=z" except that with BETWEEN, the x expression is only evaluated once. And hence I feel that your query will result into "NO records found." as there is no number which is greater than 4 and less than 2.I hope am correct.
ReplyDeleteRight Chetan :)
ReplyDelete