In my MySQL-db I have two tables
customer (NOT NULL FK)
dateOfCall (NOT NULL DATE)
timeOfCall (NOT NULL TIME).
We need to check against the last time a person received a call. Here is the updated sql.
Select cust.* from `customer` cust left join ( select customer from `call` cl group by customer having max(STR_TO_DATE(CONCAT(cl.dateOfCall, ' ', cl.timeOfCall), '%Y-%m-%d %H:%i:%s')) >= date_sub(NOW(), interval 2 hour) ) aa on cust.id = aa.customer where aa.customer is null