Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the responsive-lightbox domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114
Between Operator in SQL - Testingpool

Between Operator in SQL

Between Operator in SQL is used to filter out the output within a specified range specified in the WHERE condition.
It can be used with SELECT, INSERT,UPDATE or DELETE SQL statements.

Syntax :

SELECT  <column_name(s)>
FROM <table_name>
WHERE <column_name> BETWEEN value1 AND value2;

  • In the above Syntax , the <value1> , <value2> can either be text, numbers or dates.
  • The <column name>, <value1>, <value2> …all should be of same datatype. If they are of different
  • Datatypes then oracle does an implicit conversion. If it cannot, then it throws an error.
  • In Oracle database , the output is inclusive of the value 1 and value2 along with the values that fall between them. For e.g if range is given as BETWEEN 2000 and 3000, then the result will include all the values between them along with 2000 and 3000 themselves.

Sample Database :

SAMPLE DATABASE

Illustration of ‘BETWEEN’ using Numeric Values.

Note : The order of the numeric range should always be from Lower to Higher and not from Higher to Lower.

between operator

The query is example 1 is equivalent to :

SELECT * FROM EMP WHERE SAL >=2450 AND SAL <=3000;
Similar is the case with other examples.

Illustration of ‘BETWEEN’ using Date Values and Text Values.

Note : The Text and the Date values should be given in single quotes . Moreover values are case – sensitive. They should be given in proper case.

between operator

Illustration of ‘NOT BETWEEN’ using Number values.

Not Between

Illustration of ‘NOT BETWEEN’ using Date Values.

not between

Illustration of ‘NOT BETWEEN’ using Text Values.

Not Between


 

Avatar photo

Shikha Katariya

Shikha

You may also like...