Home  >  Article  >  Database  >  Does the sql statement between include boundary values?

Does the sql statement between include boundary values?

青灯夜游
青灯夜游Original
2021-02-03 16:38:3615003browse

In SQL Server, the SQL statement "between and" includes boundary values, and "not between" does not include boundary values. The "BETWEEN ... AND" statement selects a range of data between two values; these values ​​can be numeric, text, or dates.

Does the sql statement between include boundary values?

The operating environment of this tutorial: Windows 7 system, SQL Server 2008 version, Dell G3 computer.

BETWEEN Operator

Operator BETWEEN ... AND will select a range of data between two values. These values ​​can be numeric, text, or dates.

SQL BETWEEN Syntax:

SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2

Important:

Different databases handle the BETWEEN...AND operator differently. Some databases will list people between "Adams" and "Carter" but not including "Adams" and "Carter"; some databases will list people between "Adams" and "Carter" and including "Adams" and "Carter"; other databases will list people between "Adams" and "Carter", including "Adams" but not "Carter".

So, please check how your database handles the BETWEEN....AND operator!

General situation:

In SQL Server, between and includes boundary values, not between does not include boundary values. However, if you use between and to limit the date, you need to pay attention. If the date after and is to day, then the default is 00:00:00. For example: the date after and is April 6, 2017, which is equivalent to 2017-04-06 00:00:00, then 2017-04-06 15:10: The data of 34 is not far behind and needs to_char processing.

For more computer programming related knowledge, please visit: Programming Teaching! !

The above is the detailed content of Does the sql statement between include boundary values?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn