Complete the code to select rows where the column 'name' matches the pattern '^[A-Z]'.
SELECT * FROM users WHERE name [1] '^[A-Z]';
The ~ operator in PostgreSQL is used for regular expression matching. Here, it checks if 'name' starts with an uppercase letter.
Complete the code to find rows where 'email' contains digits using regex.
SELECT * FROM contacts WHERE email [1] '\\d+';
The ~ operator matches the regex pattern. Here, '\\d+' matches one or more digits in the email.
Fix the error in the query to select rows where 'phone' does not start with '+1'.
SELECT * FROM directory WHERE phone [1] '^\\+1';
The !~ operator returns true if the regex does NOT match. Here, it filters phones not starting with '+1'.
Fill in the blank to select rows where 'username' ends with digits and is case-insensitive.
SELECT * FROM users WHERE username [1] '\\d+$';
The ~* operator performs case-insensitive regex matching. The pattern '\\d+$' matches digits at the end.
Fill both blanks to select rows where 'address' contains either 'Street' or 'Avenue' using regex.
SELECT * FROM locations WHERE address [1] '[2]';
The ~ operator matches regex. The pattern 'Street|Avenue' matches either word. The semicolon ends the query.