Home > Enterprise >  Access SQL query for sorting
Access SQL query for sorting

Time:12-03

enter image description here - Relationships

Find employees who took some kind of management class (i.e., a class whose name ends with management). List employees’ last and first name, class name, and the class date. Sort the query output by last name in ascending.

I did the following, But the query is not working. Cannot find the ClassName that ends with management.

SELECT E.Last, E.First, C.ClassName, C.Date
FROM EMPLOYEES AS E, EMPLOYEE_TRAINING AS ET, CLASSES AS C
WHERE E.EmployeeID = ET.EmployeeID AND C.ClassID = ET.ClassID AND C.ClassName LIKE "Management*"
ORDER BY E.Last ASC;

CodePudding user response:

Try using the right wildcard character for the LIKE clause, which is %:

SELECT E.Last, E.First, C.ClassName, C.Date
FROM EMPLOYEES AS E
INNER JOIN EMPLOYEE_TRAINING AS ET ON E.EmployeeID = ET.EmployeeID
INNER JOIN CLASSES AS C ON C.ClassID = ET.ClassID
WHERE C.ClassName LIKE "%Management"
ORDER BY E.Last ASC;

CodePudding user response:

Replace "Management*" with "*Management" or "%Management" because you want to find ClassName that ends with Management, not start with Management

  • Related