How to Fix MySQL Error 3967 (ER_MULTIPLE_JSON_VALUES)
You get mysql error 3967 when a JSON path query returns more than one value. To fix it, change your path expression so it matches a single item. MySQL uses the symbol ER_MULTIPLE_JSON_VALUES and SQLSTATE 22034 for this specific issue. The engine stops the query and says more than one value was found on the path. This happens when a function or index expects one scalar value but gets an array. What causes mysql error 3967 in your database JSON columns let your app store flexible documents wit
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 3967 when a JSON path query returns more than one value. To fix it, change your path expression so it matches a single item.
MySQL uses the symbol ER_MULTIPLE_JSON_VALUES and SQLSTATE 22034 for this specific issue. The engine stops the query and says more than one value was found on the path. This happens when a function or index expects one scalar value but gets an array.
What causes mysql error 3967 in your database
JSON columns let your app store flexible documents with nested arrays and objects. Sometimes a query or table rule needs to read just one item from that document. If your JSON path uses a wildcard or range, it might match several elements.
When a function only accepts a single value, extra matches trigger mysql error 3967. You will often see this when you build a generated column from a JSON field. A normal generated column can only hold one value per row in the table.
If an app sends a document with two matching keys, the insert fails right away. This also happens during schema changes when you add a new index to old data. Old rows might have arrays where the new path expects a single string or number.
Another common trigger is using a scalar extraction tool on a wildcard path. If the path points to every item in a list, the engine cannot pick one. It raises SQLSTATE 22034 to protect data integrity and stop bad writes.
How to find the bad JSON path
Start by reading the exact error message in your app log or database log. The message names the specific function or index that found multiple values on the path. Next, check the table definition and look at any virtual or stored generated columns.
Find the JSON path expression used in those columns or in your failing query. Look for wildcards, array ranges, or double asterisks that scan deep into the document. These broad path rules are the main reason a query grabs more than one value.
You can test the path by running a read query on the target rows. Count how many elements the path returns for each row in the table. Rows that return a list of two or more items are breaking your rule.
JSON Web Tokens (JWT) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
When you check production data, make sure you protect sensitive user fields. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. This lets your team inspect broken JSON structures safely during a live fix.
How to fix ER_MULTIPLE_JSON_VALUES safely in production
You have two main ways to fix this error in a live database. Your choice depends on whether the path should return one item or many items. If you only need one item, make your JSON path strict and exact.
Replace any wildcard in the path with a clear array index, such as the first item. This tells the database engine to pull just one element from the matched list. Always test this change on a staging copy before you run it in production.
If your business logic needs to index every item in a JSON array, change the index. MySQL supports multi-valued indexes built specifically for JSON arrays that hold many values. A multi-valued index lets multiple array elements point back to the same data row.
When you switch to a multi-valued index, the engine expects a list of values. It will no longer throw mysql error 3967 when a row holds several matching items. You can also add a schema check in your app before saving new JSON documents.
Have your app check that fields meant for single-value columns are not arrays. This stops bad writes early and keeps your database logs clean.
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 SQLSTATE 22034 mean in MySQL?
SQLSTATE 22034 is the standard code for mysql error 3967 and ER_MULTIPLE_JSON_VALUES. It means a JSON path matched multiple values when the operation only allows one.
Why does my insert fail with ER_MULTIPLE_JSON_VALUES on an indexed table?
Your table likely has a generated column or functional index using a broad JSON path. When you insert a document with multiple matches for that path, the index build fails.
How do I allow multiple JSON values in a MySQL index?
You must use a multi-valued index instead of a standard single-value generated column index. Multi-valued indexes are designed to index several elements from a single JSON array.
Related guides
In this post