SQL Between Keyword, SQL Tutorial, Global Guide Line Technology.
Bookmark Bookmark: SQL Between Keyword, SQL Tutorial Forum | Blog |

      Home                    

Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.      
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.   
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.      
 SQL In Keyword.              
 SQL Between Keyword.
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.         
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Create Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                

SQL Tutorial >> SQL Between Keyword.


     Back             Next     



Whereas the SQL IN keyword help people to limit the selection criteria to one or more discrete values, now in SQL Tutorial you will learn that the SQL BETWEEN keyword allows for selecting a range. The syntax for the SQL BETWEEN clause is as follows:

Syntax for SQL Between Keyword

SELECT "column_name"
FROM "table_name"
WHERE "column_name" BETWEEN 'value1' AND 'value2'

This will select all rows whose column has a value between 'value1' and 'value2'.

For example, we may wish to view all records form the Employees table and criteria is this that we need to view only those employees record who are having date of birth BETWEEN 1972 to 1978.

 
FirstName LastName Email DOB Phone
Austin Hennery austin.it@gamail.com 24/11/1979 446 102-2222
Creston Narvon narvon_crest@hotmail.com 22/04/1976 443 325-4545
Kate Bladen kbladen@usa.net 01/05/1973 326 503-3232
Angela Julie julieee@yahoo.co.uk 11/12/1977 326 323-8888
Bobbi Ferguson bobi123@kiwibox.com 10/02/1970 506 252-9875
Cute Alfa cafa@gmail.com 19/05/1971 506 272-4566
 


Example of SQL Between Keyword

SELECT *
FROM Employees
WHERE DOB BETWEEN '01/01/1972' AND '01/01/1978'

Note that date may be stored in different formats in different databases. This tutorial simply choose one of the formats.

Results of SQL Between Keyword Example

FirstName LastName Email DOB Phone
Creston Narvon narvon_crest@hotmail.com 22/04/1976 443 325-4545
Kate Bladen kbladen@usa.net 01/05/1973 326 503-3232
Angela Julie julieee@yahoo.co.uk 11/12/1977 326 323-8888

     Back             Next     
 

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 181 visitors are online now