Answer:
The SQL queries are as follows:
1. select * from customer
select * from sale
select * from product
2. select name, sex from customer
3. select * from customer where sex = 'male'
4. select name, age from customer where sex = 'male'
5. select name, price, color from product
Step-by-step explanation:
Given
Tables: customer, sale, product
Required
Answer question 1 to 5
(1) All data in the given tables
To do this, we make use of the select clause to retrieve data from each of the table and * to select all data.
So, we have:
select * from customer --> This lists all data from customer table
select * from sale --> This lists all data from sale table
select * from product --> This lists all data from product table
(2) Selected details from customer table
In (1), we have:
select * from customer --> This lists all data from customer table
To retrieve selected details, we replace * with the field names.
So, we have:
select name, sex from customer
(3) Male customers
In (1), we have:
select * from customer --> This lists all data from customer table
To retrieve male customers, we introduce the where clause
So, we have:
select * from customer where sex = 'male'
(4) Name and age of male customers
In (3), we have:
select * from customer where sex = 'male'
To retrieve the name and age, we replace * with name and age. So, we have:
select name, age from customer where sex = 'male'
(5) Name, price and color of products
In (1), we have:
select * from product --> This lists all data from product table
To retrieve selected details, we replace * with the field names.
So, we have:
select name, price, color from product