Home » SQL & PL/SQL » SQL & PL/SQL » why use BETWEEN? BETWEEN vs. <= and >= (Oracle 11g)
why use BETWEEN? BETWEEN vs. <= and >= [message #619217] Sun, 20 July 2014 04:00 Go to next message
rc3d
Messages: 213
Registered: September 2013
Location: Baden-Württemberg
Senior Member
Hi

Quote from http://www.orafaq.com/node/1798

Quote:

A BETWEEN clause is internally expanded out into separate < / > clauses. For example:

SELECT *
FROM delivery_method
WHERE lower_bound <= :b
AND upper_bound >= :b


It's the same as <= and >= according OraFAQ. What's the use case of BETWEEN? When to use it? Because <= and >= is easier to read (everyone remembers that from school).
Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619218 is a reply to message #619217] Sun, 20 July 2014 04:28 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Because Oracle made it so.

By the way, which is easier to read,

Where val between lower_bound and upper_bound


Or,

Where val>=lower_bound and val<=upper_bound


Technically both are same, up to you which one to use. If you use BETWEEN, internally Oracle interprets the condition as the second one using operators.
Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619219 is a reply to message #619217] Sun, 20 July 2014 06:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
What's the use case of BETWEEN?


Which one you prefer to write?
Which one you better understand?
This is the use.

Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619225 is a reply to message #619219] Sun, 20 July 2014 08:51 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>What's the use case of BETWEEN?
BETWEEN results in shorter SQL statement
Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619231 is a reply to message #619225] Sun, 20 July 2014 09:50 Go to previous messageGo to next message
rc3d
Messages: 213
Registered: September 2013
Location: Baden-Württemberg
Senior Member
BlackSwan wrote on Sun, 20 July 2014 08:51
>What's the use case of BETWEEN?
BETWEEN results in shorter SQL statement


thanks BlackSwan.
Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619232 is a reply to message #619231] Sun, 20 July 2014 11:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

OK, so only BlackSwan can helpfully answer you and deserve your thanks, I will remember that for your next questions.

[Updated on: Sun, 20 July 2014 11:03]

Report message to a moderator

Re: why use BETWEEN? BETWEEN vs. <= and >= [message #619235 is a reply to message #619232] Sun, 20 July 2014 13:54 Go to previous message
rc3d
Messages: 213
Registered: September 2013
Location: Baden-Württemberg
Senior Member
Sorry thank you all guys
Previous Topic: Table statistics
Next Topic: Reverse Engineer any Object
Goto Forum:
  


Current Time: Fri Apr 26 04:13:55 CDT 2024