HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
HTML Tutorial

CSS Tutorial

SQL BETWEEN Operator - example

The BETWEEN operator selects values within a given range from database. The values - BETWEEN - can be numbers, text, or dates.
BETWEEN Syntax
Example 1: WHRE - BETWEEN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;


SQL BETWEEN Operator - how to create - example


Demo Database
Below is a selection from the "Products" table in database:

ID Product_Name ID_SUP ID_CAT Unit Price
1 Shirts 12 3 20 pieces 26
2 T-shirts 12 3 24 pieces 11
3 Sport shoes BIC 14 2 26 pairs 36
4 Shoes NiKE 23 1 48 pairs 67
5 Sport shoes BAC 23 1 36 pairs 24.35

BETWEEN Example
The following SQL statement from above database selects all products with a price BETWEEN 11 and 21:

Example 1
SELECT * FROM Products
WHERE Price BETWEEN 20 AND 30;

NOT BETWEEN Example
To display the products from database outside the range of the previous example, use NOT BETWEEN:

Example 2
SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;

Note: The values for BETWEEN can be numbers, text, or dates. The BETWEEN operator in SQL is inclusive: begin and end values are included.


sql between SQL BETWEEN Operator - sql tutorial

881. MySQL Tutorial
MySQL Tutorial for Beginners - Learn MySQL in simple and easy steps starting from basic to advanced concepts with examples including database programming clauses command functions administration queries and usage along with PHP in simple steps. This tuto
https://www.tutorialspoint.com/mysql/index.htm

3286. SQL BETWEEN Operator, sql tutorial
SQL BETWEEN Operator sql tutorial
https://www.agernic.com/sql-tutorial/sql-between-operator-with-example.html

2579. SQL MAX - SQL Tutorial

http://www.sql-tutorial.net/SQL-MAX.asp

2559. Copyright - SQL Tutorial

http://www.sql-tutorial.net/copyright.asp

2597. SQL - Syntax, sql tutorial
SQL - Syntax sql tutorial
http://www.agernic.com/sql-tutorial/sql-syntax.html

2567. SQL Cheat Sheet - SQL Tutorial

http://www.sql-tutorial.net/SQL-Cheat-Sheet.asp

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL BETWEEN Operator
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL CREATE DATABASE - example
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL