mysql  between  operator

the MySQL between operator is used to test whether or not a value lies within a specified range.the values can be number, text, or dates.

in other word the between operator is used to select values within a specified range.

how use the between operator with where clause in mysql

mysql  between  syntax

           select      column_name(s)

           from        table_name
                                
           where      column_name      between      begin_expr_value   and  end_expr_value;

the between operator is typically used in the where clause of select, update, insert, delete statements.


this database table use in mysql between example

below is a selection from the "user" table:

useridfirstnamelastnamesalarycity
1sandeepkumar10000india
2shyamdhaka11000jaipur
3ankitnehra12000uae
4ramkumar13000uk
5radhakumari14000uk

mysql  between  operator example

suppose you want to find user whose salary within the range of 12000 and 14000.

             mysql> select   *   from   user
                  
                 where    salary   between   12000   and  14000;

output :

useridfirstnamelastnameemailcity
3ankitnehra12000uae
4ramkumar13000uk
5radhakumari14000uk

mysql  not  between  operator example

suppose you want to find user whose salary is out of the range of 12000 and 14000.you use combine the between operator with the not operator :

                 select   *   from   user
                  
                 where    salary   not   between   12000   and  14000;

output :

useridfirstnamelastnameemailcity
1sandeepkumar10000india
2shyamdhaka11000jaipur