String Pattern Extraction in Descriptions
Beginner Mode

Sign in to watch the walkthrough video

Sign In

Objective

Given a table named products with the columns product_id, name, description, and price, write an SQL query to retrieve the product_id, name, and the first email address found within the description for each product. Only include products that have an email address in their description. The resulting list should be ordered by product_id in ascending order.

Additional information

  • An email address is defined by the pattern [email protected].
  • The extracted email should be the first occurrence found in the description.
  • Products without an email address in the description should not appear in the result.
  • Ensure the output columns are named exactly as product_id, name, and email_found.

Examples

Example 1:

Input:

products
descriptionnamepriceproduct_id
Contact support at [email protected] for warrantyLaptop9991
No email providedPhone5992
For business inquiries: [email protected]Tablet2993
Register at [email protected] for updatesCamera4994

Output:
email_foundnameproduct_id
[email protected]Laptop1
[email protected]Tablet3
[email protected]Camera4
Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →