Bird
0
0

Given the query:

medium📝 query result Q13 of 15
PostgreSQL - Full-Text Search
Given the query:
SELECT to_tsquery('fast & !slow');
What is the expected output?
A'fast' | !'slow'
BSyntax error
C'fast' & !'slow'
D'fast slow'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the operators in the query

    The query uses AND (&) between 'fast' and NOT (!) 'slow'. This means search for 'fast' but exclude 'slow'.
  2. Step 2: Check the output format of to_tsquery

    PostgreSQL returns the query as a string with words quoted and operators preserved. So output is 'fast' & !'slow'.
  3. Final Answer:

    'fast' & !'slow' -> Option C
  4. Quick Check:

    AND = & and NOT = ! in output [OK]
Quick Trick: NOT is !, AND is & in to_tsquery output [OK]
Common Mistakes:
  • Confusing OR (|) with AND (&)
  • Expecting raw words without quotes
  • Thinking the query causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes