Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
PostgreSQL - Full-Text Search
Identify the error in this query:

SELECT * FROM articles WHERE to_tsquery('database') @@ to_tsvector(content);
AMissing a WHERE clause condition
Bto_tsquery should be replaced with plainto_tsquery
CThe order of to_tsquery and to_tsvector is reversed
Dto_tsvector cannot be used on text columns
Step-by-Step Solution
Solution:
  1. Step 1: Check operator usage

    The @@ operator expects to_tsvector on the left and to_tsquery on the right.
  2. Step 2: Identify the mistake

    The query has them swapped, causing a syntax or runtime error.
  3. Final Answer:

    The order of to_tsquery and to_tsvector is reversed -> Option C
  4. Quick Check:

    Correct function order = A [OK]
Quick Trick: to_tsvector on left, to_tsquery on right of @@ [OK]
Common Mistakes:
  • Swapping to_tsvector and to_tsquery
  • Thinking plainto_tsquery is always required
  • Believing to_tsvector can't be used on text

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes