SELECT id, (SELECT count(*) FROM log_like_authoriz, (SELECT * FROM log_like_authoriz WHERE (user_id, id) in (SELECT user_id, MAX(id) FROM log_like_authoriz WHERE run_id = r.id GROUP BY user_id) HAVING type_like <> 0) s WHERE t.id = s.id) AS like_count FROM run r ORDER BY id DESC Error> SQL (1054): Unknown column 'r.id' in 'where clause'
how to correctly determine this ID value from the RUN table
SELECT count(*) FROM log_like_authoriz, (SELECT * FROM log_like_authoriz WHERE (user_id, id) in (SELECT user_id, MAX(id) FROM log_like_authoriz WHERE run_id = 19 GROUP BY user_id) HAVING type_like <> 0) s WHERE t.id = s.id This request receives all likes of type 1, for a specific run (for example, 19) by the last user_id entry (i.e. with the maximum id)
