
How to use the BETWEEN Condition in SQL
How to use the BETWEEN Condition in SQL
Learn how to use the SQL BETWEEN Condition. This tutorial demonstrates how to write a query using the BETWEEN Condition with an easy to follow example.
SQL BETWEEN Condition (and sample data):
https://www.techonthenet.com/sql/betw…
SQL Tutorials:
https://www.techonthenet.com/sql/inde…
Don’t forget to subscribe to our channel for more great SQL tutorials!
Visit us at: https://www.techonthenet.com
or follow us on:
Facebook: https://www.facebook.com/techonthenetcom
Twitter: https://twitter.com/tech_on_the_net
Pinterest: https://www.pinterest.com/techonthene…
Content
0 -> In SQL, the BETWEEN condition allows you to test
if an expression is within a range of values
7.22 -> This condition can be used in
the SELECT, INSERT, UPDATE or DELETE statement
13.32 -> The best way to understand
the BETWEEN condition is to look at an example
17.46 -> So let's get started
19.05 -> Here we have a table called suppliers
containing the following data
23.92 -> Let's write a SELECT statement that uses
the BETWEEN condition to return all suppliers
29.88 -> where the supplier_id
is between 300 and 600
34 -> We'll start by entering
SELECT * FROM suppliers
38.92 -> This tells the database to select all columns
from the suppliers table and return a result set
46.5 -> Next, we will enter the WHERE keyword
to start our WHERE clause
50.64 -> This is where we will use the BETWEEN condition
54.08 -> Since we want to return only those records where
the supplier_id is between 300 and 600 (inclusive)
60.68 -> we will enter the condition
BETWEEN 300 AND 600
66.22 -> Now let's run our query
and see what results we get
69.92 -> Our query returns all columns from the suppliers table
where the supplier_id is between 300 and 600
77.06 -> Notice that both the supplier_id value of 300
is included in the result set
82.42 -> as well as the supplier_is value of 600
86.1 -> This covers a simple example of how to
use the SQL BETWEEN condition
90.66 -> If you would like to see
more BETWEEN examples
93.38 -> or would like to download
the sample data we used for this tutorial
96.4 -> please visit our website at
TechOnTheNet.com
99.66 -> You can also try the examples
in our SQL editor on our website
104.12 -> Look for the "Try It" button
next to each example
107.48 -> If you found our tutorial helpful,
please leave a like on this video
110.7 -> and don't forget to subscribe
to our YouTube channel for more great SQL tutorials
Source: https://www.youtube.com/watch?v=oiOvdZudb_I