Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
32 views4 pages

Mysql Use Arati08

The document contains SQL queries and results from interacting with a MySQL database containing employee and department tables. Information like employee details, departments, filtering, aggregating, joining and comparing data from the tables is queried and output. Various SQL functions like SELECT, INSERT, UNION, GROUP BY, HAVING, ORDER BY, LIKE, IN are used in the queries.

Uploaded by

cseu23066
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

Mysql Use Arati08

The document contains SQL queries and results from interacting with a MySQL database containing employee and department tables. Information like employee details, departments, filtering, aggregating, joining and comparing data from the tables is queried and output. Various SQL functions like SELECT, INSERT, UNION, GROUP BY, HAVING, ORDER BY, LIKE, IN are used in the queries.

Uploaded by

cseu23066
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

mysql> use arati08;

Database changed
mysql> select*from employee;
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
| emp_id | emp_name | address | manager_id | post | joining_date |
salary | age | dept_id |
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
| 1 | Arati | Amravati | 1 | Finance officer | 2022 |
40000 | 30 | 3 |
| 10 | Akash | Amravati | 1 | account officer | 2022 |
50000 | 35 | 7 |
| 12 | Avani | Akola | 1 | Mark officer | 2021 |
50000 | 35 | 8 |
| 14 | Anurag | Yavatmall | 1 | prod officer | 2021 |
60000 | 35 | 5 |
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
4 rows in set (0.00 sec)

mysql> select*from department15;


+---------+------------+-----------+
| dept_id | dep_name | location |
+---------+------------+-----------+
| 3 | Marketing | building5 |
| 5 | Production | building3 |
| 6 | Finance | building3 |
| 7 | Account | buiding2 |
| 8 | Sales | building1 |
+---------+------------+-----------+
5 rows in set (0.00 sec)

mysql> insert into employee


values(15,"Anurag","Yavatmall",1,"clerk",2023,30000,35,6);
Query OK, 1 row affected (0.00 sec)

mysql> select*from employee where post='prod officer' UNION ALL select*from


employee where post='clerk';
+--------+----------+-----------+------------+--------------+--------------
+--------+------+---------+
| emp_id | emp_name | address | manager_id | post | joining_date | salary
| age | dept_id |
+--------+----------+-----------+------------+--------------+--------------
+--------+------+---------+
| 14 | Anurag | Yavatmall | 1 | prod officer | 2021 | 60000
| 35 | 5 |
| 15 | Anurag | Yavatmall | 1 | clerk | 2023 | 30000
| 35 | 6 |
+--------+----------+-----------+------------+--------------+--------------
+--------+------+---------+
2 rows in set (0.00 sec)
mysql> select*from employee where dept_id=8 or dept_id=7;
+--------+----------+----------+------------+-----------------+--------------
+--------+------+---------+
| emp_id | emp_name | address | manager_id | post | joining_date |
salary | age | dept_id |
+--------+----------+----------+------------+-----------------+--------------
+--------+------+---------+
| 10 | Akash | Amravati | 1 | account officer | 2022 |
50000 | 35 | 7 |
| 12 | Avani | Akola | 1 | Mark officer | 2021 |
50000 | 35 | 8 |
+--------+----------+----------+------------+-----------------+--------------
+--------+------+---------+
2 rows in set (0.00 sec)
mysql> select post,count(emp_name) from employee group by post;
+-----------------+-----------------+
| post | count(emp_name) |
+-----------------+-----------------+
| account officer | 1 |
| Analyst | 3 |
| clerk | 1 |
| Manager | 1 |
| Mark officer | 1 |
| prod officer | 1 |
+-----------------+-----------------+
6 rows in set (0.00 sec)
mysql> select post,sum(salary) from employee group by post;
+-----------------+-------------+
| post | sum(salary) |
+-----------------+-------------+
| account officer | 50000 |
| Analyst | 82000 |
| clerk | 30000 |
| Manager | 40000 |
| Mark officer | 50000 |
| prod officer | 60000 |
+-----------------+-------------+
6 rows in set (0.00 sec)
mysql> select emp_name from employee order by emp_name;
+----------+
| emp_name |
+----------+
| Akash |
| Anurag |
| Anurag |
| Arati |
| Avani |
| Shubham |
| Sumedh |
| Vanraj |
+----------+
8 rows in set (0.00 sec)
mysql> select emp_name,count(manager_id) from employee group by manager_id having
count(manager_id) >1;
+----------+-------------------+
| emp_name | count(manager_id) |
+----------+-------------------+
| Arati | 8 |
+----------+-------------------+
1 row in set (0.00 sec)
mysql> select*from employee order by salary desc;
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
| emp_id | emp_name | address | manager_id | post | joining_date |
salary | age | dept_id |
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
| 14 | Anurag | Yavatmall | 1 | prod officer | 2021 |
60000 | 35 | 5 |
| 10 | Akash | Amravati | 1 | account officer | 2022 |
50000 | 35 | 7 |
| 12 | Avani | Akola | 1 | Mark officer | 2021 |
50000 | 35 | 8 |
| 1 | Arati | Amravati | 1 | Manager | 2022 |
40000 | 30 | 3 |
| 15 | Anurag | Yavatmall | 1 | clerk | 2023 |
30000 | 35 | 6 |
| 18 | Sumedh | Akola | 1 | Analyst | 2015 |
30000 | 31 | 13 |
| 17 | Vanraj | Akola | 1 | Analyst | 2018 |
27000 | 29 | 11 |
| 16 | Shubham | Amravati | 1 | Analyst | 2019 |
25000 | 29 | 9 |
+--------+----------+-----------+------------+-----------------+--------------
+--------+------+---------+
8 rows in set (0.00 sec)
mysql> select emp_name,dep_name from employee,department15 where
employee.dept_id=department15.dept_id;
+----------+------------+
| emp_name | dep_name |
+----------+------------+
| Arati | Marketing |
| Akash | Account |
| Avani | Sales |
| Anurag | Production |
| Anurag | Finance |
| Shubham | Analyst |
| Vanraj | Analyst |
| Sumedh | Analyst |
+----------+------------+
8 rows in set (0.00 sec)
mysql> select employee.emp_name,manager.emp_name from employee as employee,employee
as manager where employee.manager_id=manager.emp_id;
+----------+----------+
| emp_name | emp_name |
+----------+----------+
| Arati | Arati |
| Akash | Arati |
| Avani | Arati |
| Anurag | Arati |
| Anurag | Arati |
| Shubham | Arati |
| Vanraj | Arati |
| Sumedh | Arati |
+----------+----------+
8 rows in set (0.00 sec)
mysql> select emp_name from employee where emp_name LIKE "A%";
+----------+
| emp_name |
+----------+
| Arati |
| Akash |
| Avani |
| Anurag |
| Anurag |
+----------+
5 rows in set (0.00 sec)
mysql> select emp_name from employee where salary >= (select salary from employee
where emp_name="Avani");
+----------+
| emp_name |
+----------+
| Akash |
| Avani |
| Anurag |
+----------+
3 rows in set (0.00 sec)
mysql> select emp_name from employee where salary <SOME (select salary from
employee where post="Manager");
+----------+
| emp_name |
+----------+
| Anurag |
| Shubham |
| Vanraj |
| Sumedh |
+----------+
4 rows in set (0.00 sec)
mysql> select emp_name from employee where manager_id IN (select emp_id from
employee where emp_name="Arati");
+----------+
| emp_name |
+----------+
| Arati |
| Akash |
| Avani |
| Anurag |
| Anurag |
| Shubham |
| Vanraj |
| Sumedh |
+----------+
8 rows in set (0.00 sec)

mysql> select*from employee where post="Analyst" MINUS select*from employee where


post="Manager";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'MINUS
select*from employee where post="Manager"' at line 1

You might also like