Complete the code to select the first 5 characters of the name column.
SELECT [1](name, 5) FROM employees;
The LEFT function extracts the leftmost characters from a string. Here, it gets the first 5 characters of the name.
Complete the code to find the position of 'a' in the city column.
SELECT [1]('a', city) FROM locations;
The LOCATE function returns the position of a substring in a string. It returns the first occurrence of 'a' in city.
Fix the error in the code to convert the email column to lowercase.
SELECT [1](email) FROM users;The correct function to convert text to lowercase in MySQL is LOWER. Other options are invalid or do not exist.
Fill both blanks to extract the domain from an email address.
SELECT SUBSTRING(email, [1], [2]) AS domain FROM users;
The domain starts right after '@', so we add 1 to its position for the start. The length is the total length of the email minus the position of '@' to get the rest of the string.
Fill all three blanks to create a query that replaces 'old' with 'new' in the description column and trims spaces.
SELECT TRIM([1](description, [2], [3])) AS updated_desc FROM products;
The REPLACE function replaces all occurrences of 'old' with 'new' in the description. Then TRIM removes extra spaces around the result.