Bird
0
0

Consider the query:

medium📝 Debug Q14 of 15
PostgreSQL - JSON and JSONB
Consider the query:
SELECT data #>> '{address,city}' FROM customers;
If this query returns NULL unexpectedly, what is the most likely cause?
AThe path '{address,city}' does not exist in some JSON rows
BThe operator #>> is used incorrectly and should be #>
CThe JSON column is not valid JSON format
DThe query syntax is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Understand NULL from JSON path extraction

    If the specified path does not exist in the JSON data, the operator returns NULL.
  2. Step 2: Check other options

    The syntax is correct; #>> is valid for text extraction; invalid JSON would cause errors, not NULL.
  3. Final Answer:

    The path '{address,city}' does not exist in some JSON rows -> Option A
  4. Quick Check:

    Missing path returns NULL [OK]
Quick Trick: NULL means path missing, not syntax error [OK]
Common Mistakes:
  • Assuming syntax error causes NULL
  • Confusing #> and #>> usage
  • Ignoring missing keys in JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes