Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL Joins Exercises: Find the name and hire date of the employees who was hired after 'Jones'

MySQL Joins: Exercise-5 with Solution

Write a query to find the name (first_name, last_name) and hire date of the employees who was hired after 'Jones'.

Sample table: employees


Code:

SELECT e.first_name, e.last_name, e.hire_date 
FROM employees e 
JOIN employees davies 
ON (davies.last_name = 'Jones') 
WHERE davies.hire_date < e.hire_date;

Relational Algebra Expression:

Relational Algebra Expression: Join: Find the name and hire date of the employees who was hired after 'Jones'.

Relational Algebra Tree:

Relational Algebra Tree: Join: Find the name and hire date of the employees who was hired after 'Jones'.

Sample Output:

first_name	last_name	hire_date
Alana		Walsh		1987-09-21T04:00:00.000Z
Kevin		Feeney		1987-09-22T04:00:00.000Z
Donald		OConnell	1987-09-23T04:00:00.000Z
Douglas		Grant		1987-09-24T04:00:00.000Z
Jennifer	Whalen		1987-09-25T04:00:00.000Z
Michael		Hartstein	1987-09-26T04:00:00.000Z
Pat		Fay		1987-09-27T04:00:00.000Z
Susan		Mavris		1987-09-28T04:00:00.000Z
Hermann		Baer		1987-09-29T04:00:00.000Z
Shelley		Higgins		1987-09-30T04:00:00.000Z
William		Gietz		1987-10-01T04:00:00.000Z

 

MySQL Code Editor:

Structure of 'hr' database:

hr database

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous:Write a query to find the employee id, name (last_name) along with their manager_id and name (last_name).
Next:Write a query to get the department name and number of employees in the department.

What is the difficulty level of this exercise?