Bird
0
0

You wrote this query but it returns no rows:

medium📝 Debug Q14 of 15
PostgreSQL - Full-Text Search
You wrote this query but it returns no rows:
SELECT * FROM emails WHERE to_tsvector('english', body) @@ to_tsquery('english', 'urgent | meeting');

What is the most likely reason?
AThe body column is NULL in all rows.
BThe to_tsquery syntax is incorrect; '|' is not valid.
CThe query searches for 'urgent' OR 'meeting', but none exist in body.
Dto_tsvector cannot be used on text columns.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query logic

    The '|' operator means OR, so it matches rows containing 'urgent' or 'meeting'.
  2. Step 2: Analyze why no rows return

    If no rows match, likely none contain these words in the body column.
  3. Final Answer:

    The query searches for 'urgent' OR 'meeting', but none exist in body. -> Option C
  4. Quick Check:

    '|' means OR; no matches means words missing [OK]
Quick Trick: Check if searched words exist in text before blaming syntax [OK]
Common Mistakes:
  • Thinking '|' is invalid syntax
  • Assuming to_tsvector can't be used on text
  • Ignoring possibility of no matching data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes