MariaDB Between Inclusive Includes Both Endpoints

Published
Length
3 min read

Luis Felipe Dias

All posts

Yes, the MariaDB between inclusive includes both endpoints when you filter a range of values. The engine matches the lower bound, the upper bound, and every value in the middle. Teams use this operator to pull date logs, number ranges, and sorted text records. Still, broad database roles often let engineers query far more rows than their task requires. A small mistake in boundary dates can pull millions of sensitive rows into a local terminal. How mariadb between inclusive includes both endpoi

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 both endpoints when you filter a range of values. The engine matches the lower bound, the upper bound, and every value in the middle. Teams use this operator to pull date logs, number ranges, and sorted text records. Still, broad database roles often let engineers query far more rows than their task requires. A small mistake in boundary dates can pull millions of sensitive rows into a local terminal.

How mariadb between inclusive includes both endpoints

When you run a range query in MariaDB, the engine checks both boundary values. It treats the range check just like a pair of greater-than-or-equal and less-than-or-equal filters. If a column value equals the start value or end value, MariaDB returns that row. You must always put the smaller value first and the larger value second. If you flip the order, the query returns an empty result set right away.

Numeric checks work the way most engineers expect. A range from ten to twenty includes ten, twenty, and all numbers in the middle. Text ranges follow the character set and sorting rules set up on that column. If the column ignores case, the range check ignores case as well. Null values never match a range check, even if a boundary value is null.

Handling dates and timestamps with boundary checks

Date and time columns cause the most confusion when teams run inclusive range filters. A pure date column holds only the year, month, and day. Filtering from the first day to the last day of a month works fine. Both boundary days match, and you get the full month of records.

Timestamp and datetime columns add hours, minutes, and seconds to the comparison. If you give only a date string, MariaDB fills the time part with midnight. An upper bound set to a bare date stops at the very start of that day. Any event that happens later on that final day falls outside the range. To fix this, engineers either pass the full end-of-day time or use half-open date filters.

Between Inclusive Includes Both Endpoints: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native MariaDB roles leave open

MariaDB lets admins grant read permissions at the server, database, or table level. You can also restrict read rights to specific columns inside a table. These native grants decide who can log in and which tables they can read. They work well for separating app accounts from human analysts.

Still, table grants cannot control what an individual query does once a session starts. If an engineer has read rights on a customer table, they can query any range. A wide range filter can return every email, phone number, and card number in storage. Native permissions also do not require peer approval before someone runs a huge range read. Teams need query-level controls and data masking to keep live sessions safe.

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 sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.

First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Does the negative range operator exclude both boundary values in MariaDB?

Yes, adding the negative keyword before the range operator flips the filter logic. MariaDB excludes the start value, the end value, and everything inside the range. Only rows strictly below the start or strictly above the end will match.

Why did my MariaDB date range query miss records from the final day?

Your column likely stores both dates and times, such as a datetime type. Passing a date without a time sets the upper boundary to midnight at day start. Rows from later that afternoon are greater than midnight, so the query skips them.

Can range queries use an index in MariaDB?

Yes, the MariaDB query planner can use a B-tree index for inclusive range scans. The engine seeks the lower bound in the index and scans forward to the upper bound. Keep the indexed column clean of functions so the engine can use the index.

The query runs. The emails stay hidden.