GOODS:
goods_id
goods_name
и т.д., классика
CARTS
cart_id
owner_id
goods_id
....
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