0
0
PostgreSQLquery~10 mins

Pattern matching with LIKE and ILIKE 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 all names starting with 'A'.

PostgreSQL
SELECT name FROM users WHERE name [1] 'A%';
Drag options to blanks, or click blank then click option'
A=
BLIKE
CILIKE
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of LIKE, which matches exact strings only.
Using ILIKE which is case-insensitive, but the question expects case-sensitive match.
2fill in blank
medium

Complete the code to find all emails containing 'example' regardless of case.

PostgreSQL
SELECT email FROM contacts WHERE email [1] '%example%';
Drag options to blanks, or click blank then click option'
AILIKE
BLIKE
C=
DSIMILAR TO
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE which is case-sensitive and may miss matches.
Using '=' which matches exact strings only.
3fill in blank
hard

Fix the error in the query to find usernames ending with digits.

PostgreSQL
SELECT username FROM users WHERE username [1] '%[0-9]';
Drag options to blanks, or click blank then click option'
ALIKE
BILIKE
C~
DSIMILAR TO
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE or ILIKE with character classes, which causes errors or no matches.
Using ~ without proper pattern syntax.
4fill in blank
hard

Fill both blanks to find product codes starting with 'X' and ending with 'Z' ignoring case.

PostgreSQL
SELECT code FROM products WHERE code [1] '[2]';
Drag options to blanks, or click blank then click option'
AILIKE
BLIKE
CX%Z
D%XZ
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE which is case-sensitive.
Using wrong pattern like '%XZ' which means ends with 'XZ'.
5fill in blank
hard

Fill all three blanks to select all rows where description contains 'sale' case-insensitively and price is greater than 100.

PostgreSQL
SELECT * FROM items WHERE description [1] '%[2]%' AND price [3] 100;
Drag options to blanks, or click blank then click option'
AILIKE
Bsale
C>
DLIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE instead of ILIKE, missing case-insensitive match.
Using '=' instead of '>' for price comparison.