Bird
0
0

Given the table products with a JSON column info containing {"price": 100, "details": {"color": "red"}}, what is the output of this query?

medium📝 query result Q13 of 15
PostgreSQL - JSON and JSONB
Given the table products with a JSON column info containing {"price": 100, "details": {"color": "red"}}, what is the output of this query?
SELECT info->'details'->>'color' FROM products;
Ared
BNULL
C{ "color": "red" }
D"red"
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested arrow operators

    The first -> extracts the JSON object at key 'details'. The second ->> extracts the text value of 'color'.
  2. Step 2: Determine output format

    ->> returns text without quotes, so output is plain text 'red'.
  3. Final Answer:

    red -> Option A
  4. Quick Check:

    Nested -> and ->> extract text correctly [OK]
Quick Trick: Use -> for JSON, ->> for text even in nested keys [OK]
Common Mistakes:
  • Expecting JSON output with ->>
  • Including quotes in text output
  • Confusing nested operator order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes