MariaDB Between Inclusive Includes Endpoints

Published
Length
3 min read

Luis Felipe Dias

All posts

Yes, the mariadb between inclusive includes endpoints rule applies to every range query you run. When you filter rows with this operator, the database returns both boundary values by default. Data teams use this logic every day to pull financial reports and audit logs. Still, running ad-hoc range queries with broad database roles creates serious data exposure risks. How the mariadb between inclusive includes endpoints rule works In MariaDB, the range filter checks if a target value sits withi

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Yes, the mariadb between inclusive includes endpoints rule applies to every range query you run. When you filter rows with this operator, the database returns both boundary values by default. Data teams use this logic every day to pull financial reports and audit logs. Still, running ad-hoc range queries with broad database roles creates serious data exposure risks.

How the mariadb between inclusive includes endpoints rule works

In MariaDB, the range filter checks if a target value sits within two boundaries. The engine reads the expression as greater than or equal to the lower bound. At the same time, it checks for less than or equal to the upper bound. If a row matches either boundary value, the query includes that row in the output.

This boundary behavior stays the same across numbers, text strings, and date types. For numbers, a range from one to ten returns one, ten, and everything inside. For text, the database uses the column collation rules to compare the boundary letters. This means a letter range includes exact matches for both the starting and ending text strings.

Date and timestamp columns cause the most mistakes with this boundary rule. When an engineer writes a date without a time, MariaDB sets the time to midnight. A query running from Monday to Tuesday stops at the very start of Tuesday. Rows recorded later on Tuesday afternoon fall outside the upper limit and miss the report.

Why teams struggle with range queries and broad roles

To fix missing afternoon rows, developers often widen the upper boundary to the next day. Because endpoints are inclusive, a query ending on Wednesday midnight pulls in early Wednesday records. In billing or compliance jobs, that extra second of data can double count user records. Teams must check whether a column stores simple dates or full timestamps before running queries.

Native database roles solve who can log in to the server and read tables. Admins grant read roles so analysts can run range filters on production schemas. Still, table grants do not control what individual queries do after the session starts. Once logged in, an analyst can run a massive range scan across ten years of rows.

Between Inclusive Includes Endpoints: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

A wide range filter on an unindexed timestamp column can lock up server memory. Worse, a broad query pulls thousands of sensitive rows onto a local laptop at once. Native database permissions cannot inspect the query text in flight to block huge date ranges. They also do not mask sensitive fields like emails, phone numbers, or card numbers in results.

Safer practices for production range queries

Teams can avoid boundary mistakes by writing explicit comparison operators for timestamp ranges. Using a greater-than-or-equal start limit with a strict less-than end limit prevents midnight overlap. This simple habit keeps daily reports clean without needing complex math on seconds or microseconds.

On the security side, teams need controls that operate at the query and column level. Rather than trusting static database users, modern workflows inspect every statement before it runs. Dynamic data masking rewrites matched fields like national IDs or card numbers in query results. This lets engineers test date range logic on real tables while keeping sensitive fields safe.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.

With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

Does the MariaDB range operator include both the start and end values?

Yes, the operator always includes both the lower boundary and the upper boundary values. If a record matches the exact start or end value, MariaDB returns it in results.

How do you exclude the end date in a MariaDB timestamp query?

Replace the range operator with two separate comparison checks in your filter clause. Use greater than or equal for the start date, and strict less than for the end.

What happens if the first boundary is larger than the second boundary?

MariaDB always checks the first value as the minimum and the second as the maximum. If you put the larger number first, the query will return zero matching rows.

The query runs. The emails stay hidden.