0
0
PostgreSQLquery~10 mins

@@ match operator in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find rows where the column 'description' matches the text 'database'.

PostgreSQL
SELECT * FROM products WHERE description [1] 'database';
Drag options to blanks, or click blank then click option'
ALIKE
B=
C@@
DILIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE instead of @@ for full-text search.
Using = which checks exact equality, not full-text match.
2fill in blank
medium

Complete the code to search the 'content' column for the phrase 'open source' using full-text search.

PostgreSQL
SELECT * FROM articles WHERE to_tsvector(content) [1] to_tsquery('open & source');
Drag options to blanks, or click blank then click option'
A=
B@@
CLIKE
DILIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using = which does not work for tsvector and tsquery.
Using LIKE which is for pattern matching, not full-text search.
3fill in blank
hard

Fix the error in the query to correctly match 'summary' column with the search term 'performance'.

PostgreSQL
SELECT * FROM reports WHERE summary @@ [1]('performance');
Drag options to blanks, or click blank then click option'
Ato_tsquery
Bto_tsvector
Cplainto_tsquery
Dtsvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using to_tsvector which converts text to tsvector, not tsquery.
Using plainto_tsquery which is similar but less flexible.
4fill in blank
hard

Fill both blanks to create a query that matches 'notes' column against the phrase 'data analysis'.

PostgreSQL
SELECT * FROM logs WHERE [1](notes) [2] to_tsquery('data & analysis');
Drag options to blanks, or click blank then click option'
Ato_tsvector
Bto_tsquery
C@@
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of @@ for matching.
Using to_tsquery on the column instead of to_tsvector.
5fill in blank
hard

Fill all three blanks to write a query that selects 'id' and 'text' from 'messages' where 'text' matches 'urgent update'.

PostgreSQL
SELECT id, text FROM messages WHERE [1](text) [2] [3]('urgent & update');
Drag options to blanks, or click blank then click option'
Ato_tsvector
B@@
Cto_tsquery
Dplainto_tsquery
Attempts:
3 left
💡 Hint
Common Mistakes
Using plainto_tsquery which does not support boolean operators like &.
Using = instead of @@ for matching.