KnowledgeBoat Logo
|

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

ICODEINAMEPRICEBRANDNAME
G101Power Fit Exerciser20000Power Gymea
G102Aquafit Hand Grip1800Reliable
G103Cycle Bike14000Ecobike
G104Protoner Extreme Gym30000Coscore
G105Message Belt5000Message Expert
G106Cross Trainer13000GTC 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