SQL Between

SQL Between

The SQL BETWEEN returns records between two values from a select query.

Between syntax

SELECT * FROM table_name WHERE column_name BETWEEN a_value AND b_value;

Between example

Coder books table

ID Title Price Description
1 Learn SQL 20 Learn SQL language
2 Learn MySQL 22 Learn MySQL language
3 HTML book 17 Learn HTML
4 Learn PHP 20 Introduction to PHP
5 Learn PHP 20 PHP course
SELECT * FROM coder_books WHERE price between 10 and 20;

Result

ID Title Price Description
1 Learn SQL 20 Learn SQL language
3 HTML book 17 Learn HTML
4 Learn PHP 20 Introduction to PHP
5 Learn PHP 20 PHP course