0% found this document useful (0 votes)
16 views1 page

SQL Commands for Database Queries

The document provides SQL commands for various database queries related to customers and products. It includes commands to find product names by price, customer names by purchased products, total products purchased by a specific customer, update product prices, and calculate total prices for specific products. Each command is clearly stated along with its corresponding SQL syntax.

Uploaded by

Krishna Gaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

SQL Commands for Database Queries

The document provides SQL commands for various database queries related to customers and products. It includes commands to find product names by price, customer names by purchased products, total products purchased by a specific customer, update product prices, and calculate total prices for specific products. Each command is clearly stated along with its corresponding SQL syntax.

Uploaded by

Krishna Gaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Example 1: Consider the following database and write

SQL command as given


Customer (Cno, Cname, Caddress, Ccontact)
Product(Pid, Pname, price, quantity)
Purchase(Cno, Pid)
a) Find the names of all products having price 1000.
Answer: SELECT Pname FROM PRODUCT
WHERE price=1000;
b) Find the name of those customer who purchased
Dell Laptop.
Answer: SELECT Cname FROM Customer
NATURAL JOIN Purchase NATURAL JOIN Product
WHERE Pname = ‘Dell Laptop’;
c) Find the total number of products purchased by
customer ‘Ram’
Answer: SELECT COUNT(Pid) FROM Customer
NATURAL JOIN Purchase WHERE Cname = ‘Ram’ ;
d) Increase price of all product by 5%
Answer: UPDATE Product SET Price = price*1.05;
e) Find total price of Apple mobiles
Answer: SELECT SUM (Price) FROM Product
WHERE Pname = ‘Apple Mobile’;

You might also like