Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
create table #test(myID int, myText varchar(10))insert into #test(myID, myText)select 1, 'Red' union allselect 2, 'Yellow' union allselect 3, 'Blue' union allselect 4, 'Purple' select * from #testwhere myid between 1 and 3
works fine but if I change the between to
between 3 and 1
then nothing is returned.Why?!
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-08-02 : 12:33:03
BETWEEN is position sensitive. myid BETWEEN 1 and 3 translates to "myid >= 1 and myid <= 3". And, so BETWEEN 3 and 1 translates to "myid >= 3 and myid <= 1", which of course is empty