How to Fix MySQL Error 3693 (ER_REGEXP_MAX_LT_MIN)
You get mysql error 3693 when a regular expression has an inverted repetition range. To fix it, ensure the minimum count is less than or equal to the maximum. MySQL maps this issue to the ER_REGEXP_MAX_LT_MIN symbol and SQLSTATE HY000. The engine returns a clear message when this happens. It states that the maximum is less than the minimum in an interval. The database stops the query right away to prevent bad pattern matching. What causes mysql error 3693 in your queries Regular expressions
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.
You get mysql error 3693 when a regular expression has an inverted repetition range. To fix it, ensure the minimum count is less than or equal to the maximum.
MySQL maps this issue to the ER_REGEXP_MAX_LT_MIN symbol and SQLSTATE HY000. The engine returns a clear message when this happens. It states that the maximum is less than the minimum in an interval. The database stops the query right away to prevent bad pattern matching.
What causes mysql error 3693 in your queries
Regular expressions in MySQL use curly braces to set match counts. The first number inside the braces sets the minimum match count. The second number sets the maximum match count for that pattern. If the second number is smaller than the first, the engine fails. It raises ER_REGEXP_MAX_LT_MIN before scanning any table rows.
Simple typos in handwritten queries cause this problem most of the time. An engineer might type five and then two inside the braces by mistake. That tells the engine to match a character at least five times. At the same time, it limits the match to two times. That logic is impossible to run.
Dynamic query builders in an app can also trigger this bug. Some apps let users filter text or build custom search rules. If the app puts user numbers straight into the regex pattern, bad ranges happen. A user might swap the low and high bounds in a search form. The app then sends the broken interval to the database.
Automated scripts can cause this failure during data migrations too. A script might read boundary numbers from a bad source table. When it builds the pattern check, it puts the smaller number last. MySQL catches this mistake right when it compiles the expression.
How to find and fix the broken interval
Start by finding the exact query that caused the error. Check your app error logs for the ER_REGEXP_MAX_LT_MIN symbol or error code 3693. Look at the text pattern inside the failed query. Find every pair of curly braces used for counting matches.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Check the two numbers inside each pair of curly braces. Make sure the first number is smaller than or equal to the second. Swap the numbers if they are in the wrong order. If you want an exact match count, use a single number instead. If you want no upper limit, leave the second number blank after the comma.
When you check production queries, keep data safety in mind. Engineers often read query logs that hold sensitive search strings. They might also run test queries against real tables to verify a fix. Do not grant full database roles just to debug a regex failure.
Limit database roles to read-only permissions during the check. If your team tests regex rules against tables with emails or phone numbers, use data masking. Masking rewrites matched fields in results like card numbers or national IDs. This lets engineers test pattern fixes without exposing raw customer records.
How to prevent regex range errors in your app
Do not build regular expressions by pasting raw user input together. Always check min and max numbers in your app code first. Write a simple rule that compares the two values before building the query. If the max value is smaller than the min value, reject the input.
You can also swap the two numbers in the app if that fits your logic. Add unit tests for any code that builds regex filters. Test edge cases like zero, negative numbers, and swapped bounds. Catching bad ranges in the app saves database work and stops query crashes.
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
What does the ER_REGEXP_MAX_LT_MIN symbol mean in MySQL?
It means a regular expression interval has a maximum value smaller than its minimum value. MySQL uses this symbol for error code 3693 under SQLSTATE HY000.
Does mysql error 3693 corrupt table data?
No, the database engine catches this error while compiling the regular expression. The query stops before it reads or changes any rows in your tables.
Can stored procedures hide the source of error 3693?
Yes, a stored procedure or view can hold a broken regex pattern. If your app query has no curly braces, check the views and procedures it calls.
Related guides
In this post