Use LIKE - NOT LIKE - PATINDEX - CHARINDEX
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```mssql []
/* Write your T-SQL query statement below */
SELECT user_id, email
FROM Users
WHERE 
    email LIKE '[a-zA-Z0-9_]%@[a-zA-Z]%.com' 
    AND email NOT LIKE '%@%@%'
    AND PATINDEX('%[^a-zA-Z0-9_]%', LEFT(email, CHARINDEX('@', email) - 1)) = 0 
    AND PATINDEX('%[^a-zA-Z]%', SUBSTRING(email, CHARINDEX('@', email) + 1, CHARINDEX('.com', email) - CHARINDEX('@', email) - 1)) = 0
ORDER BY user_id;

```
['MS SQL Server']