Sie sind auf Seite 1von 7

Last login: Wed Feb 27 19:22:03 on ttys001

Brijeshs-MacBook-Pro:~ brijeshkuvadiya$ mysql -u root -p


Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select employee_id, first_name,


department_master46.department_name,department_master46.department_id from
mach1.employee_master46, mach1.department_master46 where
mach1.employee_master46.department_id = mach1.department_master46.department_id;
+-------------+------------+-----------------+---------------+
| employee_id | first_name | department_name | department_id |
+-------------+------------+-----------------+---------------+
| 200 | Jennifer | Human Resources | 10 |
| 201 | Michael | Marketing | 20 |
| 202 | Pat | Marketing | 20 |
| 205 | Shelly | Accounting | 110 |
| 206 | William | Accounting | 110 |
| 7 | Raj | Human Resources | 10 |
| 101 | Neena | Human Resources | 10 |
| 102 | Lex | Human Resources | 10 |
| 103 | Alexander | IT | 60 |
| 104 | Bruce | IT | 60 |
| 107 | Diana | IT | 60 |
| 124 | Kevin | Executive | 90 |
| 141 | Trenna | Executive | 90 |
| 142 | Curtis | Executive | 90 |
| 143 | Randall | Executive | 90 |
| 144 | Peter | Executive | 90 |
| 149 | Eleni | Sales | 80 |
| 178 | Kimberely | Sales | 80 |
+-------------+------------+-----------------+---------------+
18 rows in set (0.00 sec)

mysql> select employee_master46.employee_id, employee_master46.first_name as


"Manager_name", department_master46.department_name from mach1.employee_master46,
mach1.department_master46 where employee_master46.employee_id =
department_master46.manager_id and department_master46.manager_id = 200;
+-------------+--------------+-----------------+
| employee_id | Manager_name | department_name |
+-------------+--------------+-----------------+
| 200 | Jennifer | Human Resources |
+-------------+--------------+-----------------+
1 row in set (0.00 sec)

mysql> select first_name, last_name , job_title from mach1.employee_master46,


mach1.job_master46 where employee_master46.job_id = 'MK_MAN' and
job_master46.job_id = 'MK_MAN' or employee_master46.job_id = 'MK_REP' and
job_master46.job_id = 'MK_REP';
+------------+-----------+---------------------------+
| first_name | last_name | job_title |
+------------+-----------+---------------------------+
| Michael | Hartstein | Marketing Manager |
| Pat | Fay | Marketing represerntative |
+------------+-----------+---------------------------+
2 rows in set (0.00 sec)

mysql> select first_name, min_salary , max_salary from mach1.employee_master46,


mach1.job_master46 where employee_master46.job_id = job_master46.job_id;
+------------+------------+------------+
| first_name | min_salary | max_salary |
+------------+------------+------------+
| Jennifer | 3000 | 6000 |
| Michael | 9000 | 15000 |
| Pat | 4000 | 9000 |
| Shelly | 8200 | 16000 |
| William | 4200 | 9000 |
| Raj | 20000 | 40000 |
| Neena | 15000 | 30000 |
| Lex | 15000 | 30000 |
| Alexander | 4000 | 10000 |
| Bruce | 4000 | 10000 |
| Diana | 4000 | 10000 |
| Kevin | 5500 | 8500 |
| Trenna | 2000 | 5000 |
| Curtis | 2000 | 5000 |
| Randall | 2000 | 5000 |
| Peter | 2000 | 5000 |
| Eleni | 10000 | 20000 |
| Kimberely | 6000 | 12000 |
+------------+------------+------------+
18 rows in set (0.00 sec)

mysql> select department_name, street_address, postal_code, city, state_province


from mach1.department_master46, mach1.location_master46 where
department_master46.location_id = location_master46.location_id;
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
| department_name | street_address | postal_code | city
| state_province |
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
| Human Resources | 2004 Charade Rd | 98199 |
Washington | Washington |
| Shipping | 2011 Interiors Blvd | 99236 | South
San Francisco | California |
| Shipping | 2013 Interiors Blvd | 99236 | South
San Francisco | California |
| IT | 2014 Jabberwocky Rd | 26192 |
Southlake | Texas |
| Sales | Magdalen Center, The oxford science park | OX9 9ZB | Oxford
| Oxford |
| Executive | 2004 Charade Rd | 98199 |
Washington | Washington |
| Contracting | 2004 Charade Rd | 98199 |
Washington | Washington |
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
7 rows in set (0.00 sec)
mysql> select department_name, country_name, region_name from
mach1.department_master46, mach1.location_master46, mach1.region_master46,
mach1.country_master46 where department_master46.location_id =
location_master46.location_id and location_master46.country_id =
country_master46.country_id and country_master46.region_id =
region_master46.region_id;
+-----------------+--------------------------+-------------+
| department_name | country_name | region_name |
+-----------------+--------------------------+-------------+
| Human Resources | United States of America | Americas |
| Shipping | United States of America | Americas |
| Shipping | United States of America | Americas |
| IT | United States of America | Americas |
| Sales | United Kingdom | Europe |
| Executive | United States of America | Americas |
| Contracting | United States of America | Americas |
+-----------------+--------------------------+-------------+
7 rows in set (0.01 sec)

mysql> select department_name, street_address, postal_code, city, state_province


from mach1.department_master46, mach1.location_master46 where
department_master46.location_id = location_master46.location_id;
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
| department_name | street_address | postal_code | city
| state_province |
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
| Human Resources | 2004 Charade Rd | 98199 |
Washington | Washington |
| Shipping | 2011 Interiors Blvd | 99236 | South
San Francisco | California |
| Shipping | 2013 Interiors Blvd | 99236 | South
San Francisco | California |
| IT | 2014 Jabberwocky Rd | 26192 |
Southlake | Texas |
| Sales | Magdalen Center, The oxford science park | OX9 9ZB | Oxford
| Oxford |
| Executive | 2004 Charade Rd | 98199 |
Washington | Washington |
| Contracting | 2004 Charade Rd | 98199 |
Washington | Washington |
+-----------------+------------------------------------------+-------------
+---------------------+----------------+
7 rows in set (0.00 sec)

mysql> select e.employee_id, e.first_name, e.manager_id, m.first_name as


'Manager_name' from mach1.employee_master46 e, mach1.employee_master46 m where
e.manager_id = m.employee_id;
+-------------+------------+------------+--------------+
| employee_id | first_name | manager_id | Manager_name |
+-------------+------------+------------+--------------+
| 200 | Jennifer | 200 | Jennifer |
| 201 | Michael | 201 | Michael |
| 202 | Pat | 201 | Michael |
| 205 | Shelly | 205 | Shelly |
| 206 | William | 205 | Shelly |
| 7 | Raj | 7 | Raj |
| 101 | Neena | 7 | Raj |
| 102 | Lex | 7 | Raj |
| 103 | Alexander | 103 | Alexander |
| 104 | Bruce | 103 | Alexander |
| 107 | Diana | 103 | Alexander |
| 124 | Kevin | 124 | Kevin |
| 141 | Trenna | 124 | Kevin |
| 142 | Curtis | 124 | Kevin |
| 143 | Randall | 124 | Kevin |
| 144 | Peter | 124 | Kevin |
| 149 | Eleni | 149 | Eleni |
| 178 | Kimberely | 149 | Eleni |
+-------------+------------+------------+--------------+
18 rows in set (0.00 sec)

mysql> select first_name, grade_level from mach1.employee_master46 join


mach1.job_grade_master46 ON(salary between mach1.job_grade_master46.LOWEST_SAL and
mach1.JOb_grade_master46.Highest_SAL and manager_id = "124");
+------------+-------------+
| first_name | grade_level |
+------------+-------------+
| Randall | A |
| Peter | A |
| Kevin | B |
| Trenna | B |
| Curtis | B |
+------------+-------------+
5 rows in set (0.00 sec)

mysql> select last_name, job_title as "JOB", employee_master46.department_id,


department_master46.department_name from mach1.employee_master46,
mach1.department_master46, mach1.location_master46, mach1.job_master46 where
employee_master46.department_id = department_master46.department_id and
department_master46.location_id = location_master46.location_id and
location_master46.city = "Oxford" and employee_master46.job_id =
job_master46.job_id;
+-----------+----------------------+---------------+-----------------+
| last_name | JOB | department_id | department_name |
+-----------+----------------------+---------------+-----------------+
| Zlotkey | General Manager | 80 | Sales |
| Grant | Sales Representative | 80 | Sales |
+-----------+----------------------+---------------+-----------------+
2 rows in set (0.01 sec)

mysql> select e.employee_id, e.last_name, m.last_name as "Manager's Last Name",


department_name from mach1.employee_master46 e, mach1.employee_master46 m,
mach1.department_master46 where e.manager_id = m.employee_id and e.department_id =
department_master46.department_id ;
+-------------+-----------+---------------------+-----------------+
| employee_id | last_name | Manager's Last Name | department_name |
+-------------+-----------+---------------------+-----------------+
| 200 | Whalen | Whalen | Human Resources |
| 201 | Hartstein | Hartstein | Marketing |
| 202 | Fay | Hartstein | Marketing |
| 205 | Higgins | Higgins | Accounting |
| 206 | Gietz | Higgins | Accounting |
| 7 | Aryan | Aryan | Human Resources |
| 101 | Kochhar | Aryan | Human Resources |
| 102 | De Haan | Aryan | Human Resources |
| 103 | Hunold | Hunold | IT |
| 104 | Ernst | Hunold | IT |
| 107 | Lorentz | Hunold | IT |
| 124 | Mourgos | Mourgos | Executive |
| 141 | Rajs | Mourgos | Executive |
| 142 | Davies | Mourgos | Executive |
| 143 | Matos | Mourgos | Executive |
| 144 | Vargas | Mourgos | Executive |
| 149 | Zlotkey | Zlotkey | Sales |
| 178 | Grant | Zlotkey | Sales |
+-------------+-----------+---------------------+-----------------+
18 rows in set (0.00 sec)

mysql> select e.employee_id, e.first_name, e.manager_id, m.first_name as


'Manager_name' from mach1.employee_master46 e join mach1.employee_master46 m on
e.employee_id = m.manager_id order by e.employee_id ;
+-------------+------------+------------+--------------+
| employee_id | first_name | manager_id | Manager_name |
+-------------+------------+------------+--------------+
| 7 | Raj | 7 | Raj |
| 7 | Raj | 7 | Neena |
| 7 | Raj | 7 | Lex |
| 103 | Alexander | 103 | Alexander |
| 103 | Alexander | 103 | Bruce |
| 103 | Alexander | 103 | Diana |
| 124 | Kevin | 124 | Curtis |
| 124 | Kevin | 124 | Randall |
| 124 | Kevin | 124 | Peter |
| 124 | Kevin | 124 | Kevin |
| 124 | Kevin | 124 | Trenna |
| 149 | Eleni | 149 | Eleni |
| 149 | Eleni | 149 | Kimberely |
| 200 | Jennifer | 200 | Jennifer |
| 201 | Michael | 201 | Michael |
| 201 | Michael | 201 | Pat |
| 205 | Shelly | 205 | Shelly |
| 205 | Shelly | 205 | William |
+-------------+------------+------------+--------------+
18 rows in set (0.00 sec)

mysql> select department_master46.department_id, department_name,


concat(first_name, last_name) as "Employee_Name" from mach1.department_master46
left outer join mach1.employee_master46 on department_master46.department_id =
employee_master46.department_id order by department_id;
+---------------+-----------------+------------------+
| department_id | department_name | Employee_Name |
+---------------+-----------------+------------------+
| 10 | Human Resources | RajAryan |
| 10 | Human Resources | NeenaKochhar |
| 10 | Human Resources | LexDe Haan |
| 10 | Human Resources | JenniferWhalen |
| 20 | Marketing | MichaelHartstein |
| 20 | Marketing | PatFay |
| 50 | Shipping | NULL |
| 60 | IT | AlexanderHunold |
| 60 | IT | BruceErnst |
| 60 | IT | DianaLorentz |
| 80 | Sales | EleniZlotkey |
| 80 | Sales | KimberelyGrant |
| 90 | Executive | CurtisDavies |
| 90 | Executive | RandallMatos |
| 90 | Executive | PeterVargas |
| 90 | Executive | KevinMourgos |
| 90 | Executive | TrennaRajs |
| 110 | Accounting | ShellyHiggins |
| 110 | Accounting | WilliamGietz |
| 190 | Contracting | NULL |
+---------------+-----------------+------------------+
20 rows in set (0.00 sec)

mysql> select department_master46.department_name, region_name from


mach1.department_master46, mach1.location_master46, mach1.country_master46,
mach1.region_master46 where department_master46.location_id =
location_master46.location_id and location_master46.country_id =
country_master46.country_id and country_master46.region_id =
region_master46.region_id and region_name = "Europe";
+-----------------+-------------+
| department_name | region_name |
+-----------------+-------------+
| Sales | Europe |
+-----------------+-------------+
1 row in set (0.00 sec)

mysql> select concat(first_name, " ",last_name) as "Employee_Name" , max_salary


from mach1.employee_master46, mach1.job_master46 where first_name = "Peter" and
last_name = "Vargas" and employee_master46.job_id = job_master46.job_id;
+---------------+------------+
| Employee_Name | max_salary |
+---------------+------------+
| Peter Vargas | 5000 |
+---------------+------------+
1 row in set (0.00 sec)

mysql> select last_name, department_master46.department_id from


mach1.employee_master46, mach1.location_master46, mach1.department_master46,
mach1.country_master46 where employee_master46.department_id =
department_Master46.department_id and department_Master46.location_id =
location_master46.location_id and location_master46.country_id =
country_Master46.country_id and country_name = "United States of America";
+-----------+---------------+
| last_name | department_id |
+-----------+---------------+
| Whalen | 10 |
| Aryan | 10 |
| Kochhar | 10 |
| De Haan | 10 |
| Hunold | 60 |
| Ernst | 60 |
| Lorentz | 60 |
| Mourgos | 90 |
| Rajs | 90 |
| Davies | 90 |
| Matos | 90 |
| Vargas | 90 |
+-----------+---------------+
12 rows in set (0.00 sec)

mysql> SELECT concat(first_name, " " , last_name) as "Employee_name", hire_rate as


"Hire Date" FROM mach1.Employee_MASTER46 where hire_rate > '1999-05-07' order by
hire_rate;
+-------------------+------------+
| Employee_name | Hire Date |
+-------------------+------------+
| Bruce Ernst | 1999-06-09 |
| Michael Hartstein | 1999-12-11 |
| Pat Fay | 2000-01-02 |
| Neena Kochhar | 2010-05-07 |
| Diana Lorentz | 2012-03-07 |
| Jennifer Whalen | 2012-12-12 |
| Raj Aryan | 2017-06-08 |
+-------------------+------------+
7 rows in set (0.00 sec)

mysql> select concat(e.first_name, " ", e.last_name) as "Employee" , e.hire_rate


as "Emp Hired" , concat( m.first_name, " " , m.last_name) as "Manager", m.hire_rate
as "Manager Hired" from mach1.employee_master46 e, mach1.employee_master46 m where
e.manager_id = m.employee_id and e.hire_rate < m.hire_rate ;
+-----------------+------------+----------------+---------------+
| Employee | Emp Hired | Manager | Manager Hired |
+-----------------+------------+----------------+---------------+
| William Gietz | 1983-05-07 | Shelly Higgins | 1987-04-05 |
| Neena Kochhar | 2010-05-07 | Raj Aryan | 2017-06-08 |
| Lex De Haan | 1997-06-07 | Raj Aryan | 2017-06-08 |
| Randall Matos | 1995-02-07 | Kevin Mourgos | 1998-02-06 |
| Peter Vargas | 1996-04-07 | Kevin Mourgos | 1998-02-06 |
| Kimberely Grant | 1993-02-07 | Eleni Zlotkey | 1998-03-07 |
+-----------------+------------+----------------+---------------+
6 rows in set (0.00 sec)

mysql>

Das könnte Ihnen auch gefallen