-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path3436. Find Valid Emails.sql
More file actions
29 lines (25 loc) · 973 Bytes
/
3436. Find Valid Emails.sql
File metadata and controls
29 lines (25 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Question 3436. Find Valid Emails
Link: https://leetcode.com/problems/find-valid-emails/description/?envType=problem-list-v2&envId=database
Table: Users
+-----------------+---------+
| Column Name | Type |
+-----------------+---------+
| user_id | int |
| email | varchar |
+-----------------+---------+
(user_id) is the unique key for this table.
Each row contains a user's unique ID and email address.
Write a solution to find all the valid email addresses. A valid email address meets the following criteria:
It contains exactly one @ symbol.
It ends with .com.
The part before the @ symbol contains only alphanumeric characters and underscores.
The part after the @ symbol and before .com contains a domain name that contains only letters.
Return the result table ordered by user_id in ascending order.
*/
SELECT
user_id,
email
FROM Users
WHERE email ~ '^([a-zA-Z0-9]?[_]?[a-zA-Z0-9]?)*@[a-zA-Z]+\.com$'
ORDER BY user_id ASC