Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Between in SQL

Between in SQL

? BETWEEN Operator in SQL

The BETWEEN operator is used to filter the result set within a range of values. It can be used with numbers, dates, and text.


? Syntax

SELECT column1, column2FROM table_nameWHERE column_name BETWEEN value1 AND value2;
  • Includes both value1 and value2 in the range.

  • Equivalent to:

    column_name >= value1 AND column_name <= value2

? Examples

1. Numeric Range

SELECT * FROM employeesWHERE salary BETWEEN 30000 AND 60000;

Selects employees with salary from 30,000 to 60,000 inclusive.


2. Date Range

SELECT * FROM ordersWHERE order_date BETWEEN '2023-01-01' AND '2023-03-31';

Selects orders placed in first quarter of 2023.


3. Text Range (alphabetical)

SELECT * FROM productsWHERE product_name BETWEEN 'A' AND 'M';

Selects products with names starting between A and M.


?? Notes

  • BETWEEN is inclusive of the boundary values.

  • Works for numeric, date/time, and text data types.

  • Be careful with date formats and time parts in datetime values.


Want to see NOT BETWEEN or combine BETWEEN with other conditions?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql