SELECT *, SUBSTRING(mes, 1, 30) AS `mes`, DATE_FORMAT(date120, '%d.%m.%Y, %H:%i') as date_mes2
FROM mes
WHERE `user_id` = (
SELECT `user_id`
FROM `mes`
WHERE `user_id` = '{$_SESSION['login']}'
LIMIT 1
) OR `user_idor` = (
SELECT `user_idor`
FROM `mes`
WHERE `user_idor` = '{$_SESSION['login']}'
LIMIT 1
)
ORDER by id DESC
SELECT
*,
SUBSTRING(mes, 1, 30) AS `mes`,
DATE_FORMAT(date120, '%d.%m.%Y, %H:%i') as date_mes2
WHERE user_id=:login OR user_idor=:login
ORDER BY id DESC
LIMIT 1