I using a query that selects a check type "checks" and looks in the log file to find the most recent log entry referencing this check.
SELECT checks.*, logs.last_completed_on, logs.completed_by
FROM checks INNER JOIN
(
SELECT check_id, MAX(completed_on) AS last_completed_on,
completed_by FROM checks_log GROUP BY check_id
) logs
ON checks.id = logs.check_id
This query works but i need to create a view for it. This is the first time I've used views so i don't know a lot about them but i read that its not possible with this type of query...
My question is whether there was a way to restructure it in any way?
I guess another solution would be to call this query on a specific check id for every row in a table? It sounds bad practice though... and slow, but i'm not sure.
Thanks