2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-02-11 04:10:51 +00:00
According to SQL-92:
2021-02-02 15:02:10 +01:00
2021-02-11 04:10:51 +00:00
____
2021-02-11 16:56:46 +01:00
"X BETWEEN Y AND Z" is equivalent to "X >= Y AND X +<=+ Z"
2021-02-02 16:54:43 +01:00
2021-02-11 04:10:51 +00:00
____
2021-02-02 16:54:43 +01:00
2021-02-11 04:10:51 +00:00
Even if the ``++BETWEEN++`` predicate is simply syntactic sugar, using it can improve the readability of a SQL WHERE clause, and is therefore preferred.
2020-06-30 12:47:33 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
2021-02-11 04:10:51 +00:00
SELECT * FROM PERSONS
2021-02-11 16:56:46 +01:00
WHERE AGE >= 18 and AGE <= 60
2020-06-30 12:47:33 +02:00
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
2021-02-11 04:10:51 +00:00
SELECT * FROM PERSONS
WHERE AGE BETWEEN 18 and 60
2020-06-30 12:47:33 +02:00
----