How SQL BETWEEN options are used

Source: Internet
Author: User

How SQL BETWEEN options are used

The between relationship uses the WHERE clause to select values between the various data.


The relationship of between
And between's choice of a series of data between the values of the two countries. Values can be numeric, literal, or date.

The SQL syntax between

SELECT column_name (s) from
table_name
WHERE column_name
BETWEEN value1 and value2
Now let's take a look at an example.
 
   
    Address 
       City 
     
p_id LastName FirstName
1 Hansen Ola TIMOTEIVN 10 Sandnes
2 Svendson Tove BORGVN 23 Sandnes
3 Pettersen Kari STORGT 20 Stavanger
 
   
   

Now we want to select the names of the people in alphabetical order "Hanson" and "Paterson" from the above table.

We use the following SELECT statement:

 select * from Persons WHERE LastName BETWEEN ' Hansen ' and ' Pettersen ' 
 &N

  BSP; 
The
 results are the following table. 
   
 
     
      TIMOTEIVN  
     
     
     
city
1 Hansen Ola sandnes
   
 NOTE: Reprint please specify From www.111cn.net/database/database.html 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.