SQL Trigger to Automatically Update "last_updated" Column

This technical problem describes how to write a SQL trigger that will automatically update the "last_updated" column whenever a change is made to any of the other columns in a table. The example input table contains employee data, and the example output shows how the "last_updated" column would be updated after a change is made to one of the other columns.

Problem

Given a table of employee data, write a SQL trigger that will automatically update the "last_updated" column whenever a change is made to any of the other columns in the table.
Example input:
Employee table with columns: id, first_name, last_name, start_date, end_date, last_updated
id | first_name | last_name | start_date | end_date | last_updated
1 | John | Doe | 01/01/2018 | NULL | 01/01/2018
2 | Jane | Smith | 02/01/2018 | NULL | 02/01/2018
3 | Bill | Gates | 03/01/2018 | NULL | 03/01/2018
Example output:
Employee table with columns: id, first_name, last_name, start_date, end_date, last_updated
id | first_name | last_name | start_date | end_date | last_updated
1 | John | Doe | 01/01/2018 | NULL | 01/02/2018
2 | Jane | Smith | 02/01/2018 | NULL | 02/02 /2018
3 | Bill | Gates | 03/01/2018 | NULL | 03/02/2018

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
CREATE TRIGGER update_last_updated
AFTER UPDATE ON employee
FOR EACH ROW
BEGIN
  UPDATE employee
  SET last_updated = CURRENT_TIMESTAMP
  WHERE id = NEW.id;
END;

/*

The trigger above is optimal because it will update the last_updated column for every row that is updated.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of how to write a SQL trigger.

Evaluated at: 2022-11-21 12:16:30