MariaDB Between Inclusive

Published
Length
3 min read

Luis Felipe Dias

All posts

Yes, the mariadb between inclusive rule applies to both start and end values. When you filter data with this operator, the database returns the boundary matches too. Data teams use this logic every day to pull reports by date or number. Still, broad read roles let users run huge range queries on live tables. A single wide range scan can lock rows or slow down the whole server. How the mariadb between inclusive operator works In MariaDB, a range filter checks if a value sits inside two limits.

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 rule applies to both start and end values. When you filter data with this operator, the database returns the boundary matches too. Data teams use this logic every day to pull reports by date or number. Still, broad read roles let users run huge range queries on live tables. A single wide range scan can lock rows or slow down the whole server.

How the mariadb between inclusive operator works

In MariaDB, a range filter checks if a value sits inside two limits. The engine treats the lower limit and the upper limit as part of the match. If a row matches the exact start value, MariaDB puts it in the result set. If a row matches the exact end value, the database returns that row too. This behavior matches two separate greater-than-or-equal and less-than-or-equal checks.

The order of your limits matters when you write the query. You must put the smaller value first and the larger value second. If you flip the two values, the query returns an empty set. Numeric ranges work in a clear way because whole numbers and decimals have fixed steps. Text ranges follow the sort rules of the column character set. If a column ignores letter case, the range check ignores letter case as well.

How date and time boundaries behave in range checks

Date and time columns cause the most confusion during range queries. A pure date column holds only the year, month, and day. When you filter a pure date column, both the start date and end date match. The problem starts when you filter a full timestamp column using short date strings.

When you give a short date string, MariaDB adds a midnight time value to it. The start boundary begins at the very first second of the first day. The end boundary stops at the very first second of the last day. Any row with a timestamp later on that final day falls outside the range. To get the whole final day, teams must set the end time to the last second. Many analysts also use a half-open range with a less-than check for the next day. If either boundary is null, the database returns no rows at all.

Between Inclusive: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why native roles leave a gap for large range queries

Native MariaDB roles control which tables a user or app can read. An admin grants read rights on a schema or table to a team role. Once a user logs in with that role, every select statement is valid. Native grants decide who logs in, not what individual statements do in flight.

A user with read rights can pull ten years of records in one range check. That query scans millions of rows and returns sensitive fields in the results. If the table holds emails, phone numbers, card numbers, or national IDs, everything comes back raw. Database logs often capture only the login event unless full query logs are on. Turning on full query logs on a busy server hurts disk speed right away. Teams need a way to inspect queries and mask sensitive fields in results.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.

First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Does MariaDB include both endpoints in a range query?

Yes, MariaDB includes both the start value and the end value in the results. Any row that equals the lower bound or the upper bound will match the filter.

Why did my timestamp range query miss records from the last day?

A date string without a time part defaults to midnight at the start of that day. Records created later on that final day sit past the upper boundary and get skipped.

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

MariaDB does not swap the two values for you when you run the query. The check looks for values above the high mark and below the low mark, returning nothing.

The query runs. The emails stay hidden.