Mysql Questions
Mysql Questions
MYSQL
(QUESTION FOR MYSQL EXAM)
------------------------+------------------------------+----------+----------+
+
| first_name
| last_name | age | dept |
+------------------------+------------------------------+----------+----------+
| Mesa
| Loop | 30 | Acct |
| Smith
| Oak | 27 | Devl |
| John
| Jorz | 37 | QA |
| Hary
| Gaga | 32 | QA |
+
+------------------------+------------------------------+----------+----------
b. W
rite a mysql statement to get item id, item, price of the most expensive item.(4
marks)
d. W
rite a MySQL statement to select data of all departments in descending order
by age. (5 marks)
e. Write a mysql statement to determine the age of each of the students.(5 marks)
f. Write a mysql statement to retrieve names beginning with 'm' or ‘M’ (4 marks)
i. P rint 2 random students from the table. (Table is same as 04.h) ( 4 marks)
j. Update the table in id 4,6 . ( 4 marks)
id | name
| | email | phone
|
+----+--------------+------------+---------------------+
| 1 | Maria Gloria | [email protected]
| 123456789 |
| 2 | John Smith
| [email protected] | 123456789 |
| 3 | Gal Rao
| [email protected] | 123456789 |
| 4 | Jakey Smith | [email protected]
| 123456789 |
| 5 | Rama Saho
|
[email protected] | 123456789 |
| 6 | Maria Gaga
| [email protected] | 123456789 |
+----+--------------+------------+---------------------+
k. Display details of highest and lowest data using one syntax. ( 4 marks)
----+----------+--------+
+
| id | emp_name | salary |
+----+----------+--------+
| 1 | Smith
| 30000 |
| 2 | Joney
| 20000 |
| 3 | Mariya
| 40000 |
| 4 | Zoya
| 35000 |
| 5 | Smith
| 25000 |
| 6 | Rosy
| 75000 |
+----+----------+--------+
l. Display the first 4 highly paid salaries using mysql. ( 4 marks)
----+----------+--------+
+
| id | emp_name | salary |
+----+----------+--------+
| 1 | Smith
| 30000 |
| 2 | Joney
| 20000 |
| 3 | Mariya
| 40000 |
| 4 | Zoya
| 35000 |
| 5 | Smith
| 25000 |
| 6 | Rosy
| 75000 |
+----+----------+--------+
m. Add the phone column in the table. ( 4 marks)
----+----------+--------+
+
| id | emp_name | salary |
+----+----------+--------+
| 1 | Smith
| 30000 |
| 2 | Joney
| 20000 |
| 3 | Mariya
| 40000 |
| 4 | Zoya
| 35000 |
| 5 | Smith
| 25000 |
| 6 | Rosy
| 75000 |
+----+----------+--------+
n. P
hone columns are null. Add phone number 123456789 in all queries. ( 4
marks)
----+----------+--------+-------+
+
| id | emp_name | salary | phone |
+----+----------+--------+-------+
| 1 | Smith
| 30000 | NULL |
| 2 | Joney
| 20000 | NULL |
| 3 | Mariya
| 40000 | NULL |
| 4 | Zoya
| 35000 | NULL |
| 5 | Smith
| 25000 | NULL |
| 6 | Rosy
| 75000 | NULL |
+----+----------+--------+-------+
END QUESTION