0
0
PostgreSQLquery~10 mins

SIMILAR TO for regex-lite matching 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 select names that start with 'A' using SIMILAR TO.

PostgreSQL
SELECT name FROM employees WHERE name [1] 'A%';
Drag options to blanks, or click blank then click option'
ASIMILAR TO
BLIKE
CILIKE
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE instead of SIMILAR TO for regex-like matching.
Using = which checks exact equality.
2fill in blank
medium

Complete the code to find emails ending with '.com' using SIMILAR TO.

PostgreSQL
SELECT email FROM users WHERE email [1] '%\.com';
Drag options to blanks, or click blank then click option'
ASIMILAR TO
BLIKE
CILIKE
DNOT LIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Not escaping the dot '.' causing wrong matches.
Using LIKE which does not support regex escapes.
3fill in blank
hard

Fix the error in the query to match phone numbers with exactly 10 digits using SIMILAR TO.

PostgreSQL
SELECT phone FROM contacts WHERE phone [1] '[0-9]{10}';
Drag options to blanks, or click blank then click option'
ALIKE
BSIMILAR TO
C=
DILIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE which does not support regex quantifiers.
Using = which checks exact string equality.
4fill in blank
hard

Fill both blanks to select usernames starting with a letter and followed by digits using SIMILAR TO.

PostgreSQL
SELECT username FROM accounts WHERE username [1] '[2][0-9]+';
Drag options to blanks, or click blank then click option'
ASIMILAR TO
BLIKE
C[A-Za-z]
D[0-9]
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE instead of SIMILAR TO.
Using wrong character class for the first character.
5fill in blank
hard

Fill all three blanks to select product codes that start with 'P', followed by 3 digits, and end with a letter using SIMILAR TO.

PostgreSQL
SELECT product_code FROM inventory WHERE product_code [1] '[2][3][A-Za-z]';
Drag options to blanks, or click blank then click option'
ASIMILAR TO
BP
C[0-9]{3}
DLIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using LIKE instead of SIMILAR TO.
Not using quantifier {3} for digits.
Missing the starting 'P' in the pattern.