SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 22 
WHERE 
  cscart_products_categories.product_id IN (
    51830, 51829, 59337, 52214, 51828, 51816, 
    51812, 51811, 51786, 51785, 51813, 
    51802, 51801, 51800, 51799, 51798, 
    51797, 51796, 51795, 51794, 51793, 
    51792, 51791, 51790, 51789, 51788, 
    51753, 51752, 51751, 51750, 51782, 
    51735, 91670, 91669, 91668, 51653, 
    51646, 51638, 51637, 51636, 51635, 
    111382, 51609, 51605, 51587, 51581, 
    51580, 51666, 51665, 51664, 51663, 
    51662, 51557, 51555, 51534, 51533, 
    51532, 51531, 51530, 51529, 51520, 
    51437, 51694, 51430, 51425, 51338, 
    51337, 51319, 51768, 51418, 51287, 
    51198, 51127, 51126, 51098, 51097, 
    51096, 51095, 51094, 51093
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00087

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 91 Using where; Using index
1 SIMPLE cscart_categories eq_ref PRIMARY,c_status,p_category_id PRIMARY 3 toolboxdigitalshop_dev.cscart_products_categories.category_id 1 Using where
1 SIMPLE product_position_source eq_ref PRIMARY,pt PRIMARY 6 const,toolboxdigitalshop_dev.cscart_products_categories.product_id 1

Result

product_id category_ids position
51093 22M 0
51094 22M 0
51095 22M 0
51096 22M 0
51097 22M 0
51098 22M 0
51126 22M 0
51127 22M 0
51198 22M 0
51287 22M 0
51319 22M 0
51337 22M 0
51338 22M 0
51418 22M 0
51425 34,22M 0
51430 22M 0
51437 22M 0
51520 22M 0
51529 22M 0
51530 22M 0
51531 22M 0
51532 22M 0
51533 22M 0
51534 22M 0
51555 22M 0
51557 22M 0
51580 32,22M 0
51581 32,22M 0
51587 22M 0
51605 22M 0
51609 22M 0
51635 32,22M 0
51636 33,22M 0
51637 22M 0
51638 22M 0
51646 22M 0
51653 33,22M 0
51662 33,22M 0
51663 33,22M 0
51664 33,22M 0
51665 33,22M 0
51666 33,22M 0
51694 22M 0
51735 22M 0
51750 22M 0
51751 22M 0
51752 22M 0
51753 22M 0
51768 22M 0
51782 22M 0
51785 22M 0
51786 22M 0
51788 22M 0
51789 22M 0
51790 22M 0
51791 22M 0
51792 22M 0
51793 22M 0
51794 22M 0
51795 22M 0
51796 22M 0
51797 22M 0
51798 22M 0
51799 22M 0
51800 22M 0
51801 22M 0
51802 22M 0
51811 22M 0
51812 22M 0
51813 22M 0
51816 22M 0
51828 22M 0
51829 22M 0
51830 22M 0
52214 22M 0
59337 22M 0
91668 22M 0
91669 22M 0
91670 22M 0
111382 22M 0