152k views
1 vote
List customers who have purchased products with names beginning with "Trangia". Show the First name, last name, email address and product name. If a customer has puchased the same product more than once, show a row for each time the product was purchased. Name the query "Trangia Buyers" (without the quotes).

User Poovaraj
by
7.7k points

2 Answers

2 votes

Final answer:

The SQL query to list customers who have purchased products with names beginning with "Trangia" and show their first name, last name, email address, and product name.

Step-by-step explanation:

The SQL query to list customers who have purchased products with names beginning with "Trangia" and show their first name, last name, email address, and product name is:

SELECT customer.first_name, customer.last_name, customer.email, product.name FROM customer JOIN purchase ON customer.id = purchase.customer_id JOIN product ON product.id = purchase.product_id WHERE product.name LIKE 'Trangia%';

This query uses the SELECT, JOIN, and WHERE clauses to retrieve the required information from the database.

User Victor Eijkhout
by
7.6k points
5 votes

This assumes that you have a structure where customers are linked to orders through a common ID (e.g., Customer_ID), and orders are linked to products through another common ID (e.g., Product_ID). Adjust the table and column names based on your specific database schema.

SELECT

Customers.First_Name,

Customers.Last_Name,

Customers.Email_Address,

Products.Product_Name

FROM

Customers

JOIN

Orders ON Customers.Customer_ID = Orders.Customer_ID

JOIN

Products ON Orders.Product_ID = Products.Product_ID

WHERE

Products.Product_Name LIKE 'Trangia%'

ORDER BY

Customers.Last_Name, Customers.First_Name, Products.Product_Name;

User Lance Pioch
by
8.4k points