SQL Problems


SQL Query to Find Users with a Valid Email Address

This problem asks for a SQL query to find all users in a table who have a valid email address.

Problem

Given a table of user data, write a SQL query to find all users who have a valid email address.
Input:
User table with columns: id, name, email
Output:
List of all users with a valid email address

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by AskAI
SELECT * FROM User WHERE email LIKE '%@%'

/*

The above solution is optimal because it uses the LIKE operator to check if the email contains an @ symbol.

*/

A.I. Evaluation of the Solution

The solution correctly uses the LIKE operator to check if the email contains an @ symbol.

Evaluated at: 2022-10-31 02:36:00

Community solutions:

Check these solutions from our community and artificial intelligence:
This solution is incomplete because it does not account for email addresses that may have more than one '@' character. A more complete solution would use a regular expression to match email addresses.