I I Iiiiii Sssss
I I Iiiiii Sssss
I I Iiiiii Sssss
2. Use.
mysql> use office Database
changed
3. Table showing.
mysql> show tables;
+------------------+
| Tables_in_office |
+------------------+
| workers |
+------------------+
4. Insert.
mysql> insert into workers (e_id,e_name,e_salary,e_age,e_gender,e_dept) values (1,'Sam',95000,45,'Mal
e','Operations');
Query OK, 1 row affected (0.01 sec)
5. Select.
mysql> select * from workers;
+------+--------+----------+-------+----------+------------+
| e_id | e_name | e_salary | e_age | e_gender | e_dept |
+------+--------+----------+-------+----------+------------+
| 1 | Sam | 95000 | 45 | Male | Operations |
| 2 | Bob | 80000 | 21 | Male | Support |
| 3 | Anne | 125000 | 25 | Female | Analysis |
| 4 | Julia | 73000 | 30 | Female | Analysis |
| 5 | Matt | 159000 | 33 | Male | Sales |
| 6 | Jeff | 112000 | 27 | Male | Operations |
+------+--------+----------+-------+----------+------------+
6. Sum.
mysql> select sum(e_salary) from workers;
+---------------+
| sum(e_salary) |
+---------------+
| 644000 |
+---------------+
7. Avg.
mysql> select avg(e_salary) from workers;
+---------------+
| avg(e_salary) |
+---------------+
| 107333.3333 |
+---------------+
1 row in set (0.00 sec)
8. Max.
mysql> select max(e_salary) from workers;
+---------------+
| max(e_salary) |
+---------------+
| 159000 |
+---------------+
9. Min.
mysql> select min(e_salary) from workers;
+---------------+
| min(e_salary) |
+---------------+
| 73000 |
+---------------+
10.Count.
mysql> select count(e_id) from workers;
+-------------+
| count(e_id) |
+-------------+
| 6 | +-------------+
11.Where.
mysql> select * from workers where e_age > 21;
+------+--------+----------+-------+----------+------------+
| e_id | e_name | e_salary | e_age | e_gender | e_dept |
+------+--------+----------+-------+----------+------------+
| 1 | Sam | 95000 | 45 | Male | Operations |
| 3 | Anne | 125000 | 25 | Female | Analysis |
| 4 | Julia | 73000 | 30 | Female | Analysis |
| 5 | Matt | 159000 | 33 | Male | Sales |
| 6 | Jeff | 112000 | 27 | Male | Operations |
+------+--------+----------+-------+----------+------------+
12.Like.
mysql> select * from workers where e_gender like 'Female';
+------+--------+----------+-------+----------+----------+
| e_id | e_name | e_salary | e_age | e_gender | e_dept |
+------+--------+----------+-------+----------+----------+
| 3 | Anne | 125000 | 25 | Female | Analysis |
| 4 | Julia | 73000 | 30 | Female | Analysis |
+------+--------+----------+-------+----------+----------+
2 rows in set (0.00 sec)