Using Database Functions On Where Conditions

Here we have another example of how we can use database functions to simplify our requirement to view a list of employees who were hired in the year 2003. Once again we use a Field class but we couple it with a WhereCondition class to provide the WHERE condition for our SQL statement. See the Java tab below on how we accomplish this task.
We want a SELECT statement that looks like this:

SELECT employees.first_name,employees.last_name, employees.start_date FROM employees WHERE YEAR(employees.start_date) = 2003 ORDER BY employees.last_name;

For this example we make use of the function YEAR() to place a condition on the SQL statement which filters all our records and provides only those whose start date occurred in the year 2003. The end result is a presorted list of employees with their start dates.

Live example

First Name Last Name Start Date
Loading data from server
First Name Last Name Start Date