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
with carts_goods_id as (
select distinct goods_id from carts where owner_id=?
)
select
goods.*,
case when carts_goods_id.goods_id is not null
then 'в корзине'
else ''
end carts_mark
from goods
left join carts_goods_id on goods.goods_id=carts_goods_id.goods_id