Bird
0
0

Which of the following is the correct syntax to use the @@ operator with to_tsquery in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Full-Text Search

Which of the following is the correct syntax to use the @@ operator with to_tsquery in PostgreSQL?

SELECT * FROM articles WHERE content @@ to_tsquery('search_term');
ASELECT * FROM articles WHERE content @@ to_tsquery('search_term');
BSELECT * FROM articles WHERE content = to_tsquery('search_term');
CSELECT * FROM articles WHERE content @@ 'search_term';
DSELECT * FROM articles WHERE content LIKE to_tsquery('search_term');
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct usage of @@ with to_tsquery

    The @@ operator requires the right side to be a tsquery, which is created by to_tsquery().
  2. Step 2: Check each option

    SELECT * FROM articles WHERE content @@ to_tsquery('search_term'); correctly uses content @@ to_tsquery('search_term'). Options B, C, and D misuse operators or omit to_tsquery().
  3. Final Answer:

    SELECT * FROM articles WHERE content @@ to_tsquery('search_term'); -> Option A
  4. Quick Check:

    Use @@ to_tsquery() syntax [OK]
Quick Trick: Always use to_tsquery() on right side of @@ [OK]
Common Mistakes:
  • Using = instead of @@
  • Passing plain string without to_tsquery()
  • Using LIKE operator for full-text search

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes