Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
PostgreSQL - JSON and JSONB
Identify the error in this query:
SELECT info->>age FROM customers;
Assuming info is a JSON column.
AMissing quotes around 'age' key
BUsing ->> instead of ->
Cinfo column is not JSON type
DNo error, query is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check JSON key syntax

    JSON keys must be string literals in quotes when used with -> or ->> operators.
  2. Step 2: Identify missing quotes

    The key age is not quoted, causing a syntax error.
  3. Final Answer:

    Missing quotes around 'age' key -> Option A
  4. Quick Check:

    JSON keys require quotes in -> and ->> [OK]
Quick Trick: Always quote JSON keys as strings [OK]
Common Mistakes:
  • Omitting quotes around JSON keys
  • Confusing -> and ->> usage
  • Assuming JSON keys can be unquoted identifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes