KnowledgeBoat Logo

Informatics Practices

Consider the table Product shown below:

Table: PRODUCT

P_IDProductNameManufacturerPrice
P001MoisturizerXYZ40
P002SanitizerLAC35
P003Bath SoapCOP25
P004ShampooTAP95
P005Lens SolutionCOP350

Write the commands in SQL queries for the following:

(a) To display the details of product whose price is in the range of 40 and 120 (both values included).

(b) To increase the price of all the products by 20.

SQL Queries

1 Like

Answer

(a)

SELECT * 
FROM PRODUCT 
WHERE PRICE BETWEEN 40 AND 120;
Output
+------+-------------+--------------+-------+
| P_ID | ProductName | Manufacturer | Price |
+------+-------------+--------------+-------+
| P001 | MOISTURISER | XYZ          |    40 |
| P004 | SHAMPOO     | TAP          |    95 |
+------+-------------+--------------+-------+

(b)

UPDATE PRODUCT 
SET PRICE = PRICE + 20;

Answered By

3 Likes


Related Questions