Write an SQL statement utilizing the WHERE, LIKE, and HAVING clauses that selects gender, and the email addresses that belong to female users and have an email address that contains a number (0 to 9) within it. Create an alias for the resultant email column name and name it ‘Email Addresses Female With Numbers’.
SELECT gender, email as "Email Addresses Female With Numbers" FROM users WHERE gender = 'f' AND email RLIKE '[0-9]'
RLIKE is an operator similar to LIKE, but the user is not limited to search for a string based on a fixed pattern with the % & _ signs. The pattern in this case is a regex which allows the construction of more flexible patterns.
We cannot use the HAVING clause in the above query because for using this clause we must either have to use the GROUP BY clause which is used to group elements or there must be some aggregate functions. Since none of the conditions are required for the above query so we cannot use the HAVING clause.
Hope this helps. If you have any queries or suggestions regarding the answers please leave them in the comments section so I can update and improve the answer. Thank you.
Get Answers For Free
Most questions answered within 1 hours.