SELECT
f.*
FROM
films f
LEFT JOIN meta_films m ON
m.id_films = f.id
AND m.meta_value IN(13, 23)
WHERE
m.id_films IS NOT NULL
GROUP BY f.id
SELECT
`act_tmp`.*,
`users`.`name`,
`users`.`lname`,
`users`.`ava_file`
FROM
`users`
LEFT JOIN(
SELECT `act`.*
FROM
`act`
LEFT JOIN(
SELECT
`creator`,
MAX(`date`) AS `date`
FROM
`act`
WHERE
`act`.`date` > "1517427936" AND `act`.`date` < "1517428356"
GROUP BY
`creator`
) AS `act_b`
ON
`act`.`creator` = `act_b`.`creator` AND `act`.`date` = `act_b`.`date`
WHERE
`act_b`.`creator` IS NOT NULL
GROUP BY
`act`.`creator`
) AS `act_tmp`
ON
`users`.`id` = `act_tmp`.`creator`
WHERE
`act_tmp`.`creator` IS NOT NULL
GROUP BY
`users`.`id`