Informatics Practices
Consider the following table named "GYM" with details about fitness items being sold in the store. Write command of SQL for (i) to (iv).
Table : GYM
| ICODE | INAME | PRICE | BRANDNAME |
|---|---|---|---|
| G101 | Power Fit Exerciser | 20000 | Power Gymea |
| G102 | Aquafit Hand Grip | 1800 | Reliable |
| G103 | Cycle Bike | 14000 | Ecobike |
| G104 | Protoner Extreme Gym | 30000 | Coscore |
| G105 | Message Belt | 5000 | Message Expert |
| G106 | Cross Trainer | 13000 | GTC Fitness |
(i) To display the names of all the items whose name starts with "A".
(ii) To display ICODEs and INAMEs of all items, whose Brandname is Reliable or Coscore.
(iii) To change the Brandname to "Fit Trend India" of the item, whose ICODE as "G101".
(iv) Add a new row for new item in GYM with the details :
"G107", "Vibro exerciser", 21000, "GTCFitness"
SQL Queries
20 Likes
Answer
(i)
SELECT INAME
FROM GYM
WHERE INAME LIKE 'A%';
Output
+-------------------+
| INAME |
+-------------------+
| Aquafit Hand Grip |
+-------------------+
(ii)
SELECT ICODE, INAME
FROM GYM
WHERE BRANDNAME = "Reliable" OR BRANDNAME = "Coscore";
Output
+-------+----------------------+
| ICODE | INAME |
+-------+----------------------+
| G102 | Aquafit Hand Grip |
| G104 | Protoner Extreme Gym |
+-------+----------------------+
(iii)
UPDATE GYM
SET BRANDNAME = 'Fit Trend India'
WHERE ICODE = 'G101';
(iv)
INSERT INTO GYM
VALUES("G107", "Vibro exerciser", 21000, "GTCFitness");
Answered By
12 Likes
Related Questions
What is the use of UPDATE statement in SQL ? How is it different from ALTER statement ?
Mr. Shankar created a table VEHICLE with 3 rows and 4 columns. He added 1 more row to it and deleted one column. What is the Cardinality and Degree of the Table VEHICLE ?
Mr. James created a table CLIENT with 2 rows and 4 columns. He added 2 more rows to it and deleted one column. What is the Cardinality and Degree of the Table CLIENT ?
Consider the following table FITNESS with details about fitness products being sold in the store. Write command of SQL for (i) to (iv).
Table : FITNESS
PCODE PNAME PRICE Manufacturer P1 Treadmill 21000 Coscore P2 Bike 20000 Aone P3 Cross Trainer 14000 Reliable P4 Multi Gym 34000 Coscore P5 Massage Chair 5500 Regrosene P6 Belly Vibrator Belt 6500 Ambawya (i) To display the names of all the products with price more than 20000.
(ii) To display the names of all products by the manufacturer "Aone".
(iii) To change the price data of all the products by applying 25% discount reduction.
(iv) To add a new row for product with the details :
"P7", "Vibro Exerciser", 28000, "Aone".