-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1517. Find Users With Valid E-Mails.sql
More file actions
32 lines (25 loc) · 1.02 KB
/
1517. Find Users With Valid E-Mails.sql
File metadata and controls
32 lines (25 loc) · 1.02 KB
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
30
31
32
/*
Question 1517. Find Users With Valid E-Mails
Link: https://leetcode.com/problems/find-users-with-valid-e-mails/description/?envType=study-plan-v2&envId=top-sql-50
Table: Users
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| user_id | int |
| name | varchar |
| mail | varchar |
+---------------+---------+
user_id is the primary key (column with unique values) for this table.
This table contains information of the users signed up in a website. Some e-mails are invalid.
Write a solution to find the users who have valid emails.
A valid e-mail has a prefix name and a domain where:
The prefix name is a string that may contain letters (upper or lower case), digits, underscore '_', period '.', and/or dash '-'. The prefix name must start with a letter.
The domain is '@leetcode.com'.
Return the result table in any order.
*/
SELECT
user_id,
name, --noqa: RF04
mail
FROM Users
WHERE mail ~ '^[a-zA-Z]+([a-zA-Z0-9]?[._-]?[a-zA-Z0-9]?)*@leetcode\.com$'