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 (
    38980, 38979, 38978, 38977, 38950, 38949, 
    39126, 38968, 38962, 38961, 38960, 
    38959, 38958, 38957, 38956, 38955, 
    38954, 38953, 38952, 38951, 38930, 
    39545, 39544, 39543, 39542, 39541, 
    39540, 39539, 39538, 39537, 39536, 
    39535, 39534, 39533, 39532, 39531, 
    39530, 39529, 39528, 39527, 39526, 
    39525, 39524, 39523, 39522, 39521, 
    39492, 39491, 39490, 39489, 39488, 
    39487, 39486, 39485, 39484, 39483, 
    39482, 39481, 39480, 39479, 39478, 
    39477, 39476, 39475, 39474, 39473, 
    39357, 39356, 39355, 39354, 39353, 
    39352, 39351, 39350, 39349, 39348, 
    39347, 39346, 39345, 39344
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00078

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 86 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
38930 22M 0
38949 22M 0
38950 22M 0
38951 22M 0
38952 32,22M 0
38953 22M 0
38954 22M 0
38955 22M 0
38956 32,22M 0
38957 22M 0
38958 32,22M 0
38959 32,22M 0
38960 32,22M 0
38961 22M 0
38962 32,22M 0
38968 22M 0
38977 22M 0
38978 22M 0
38979 22M 0
38980 22M 0
39126 22M 0
39344 22M 0
39345 22M 0
39346 22M 0
39347 22M 0
39348 22M 0
39349 22M 0
39350 22M 0
39351 22M 0
39352 22M 0
39353 22M 0
39354 22M 0
39355 22M 0
39356 22M 0
39357 22M 0
39473 22M 0
39474 22M 0
39475 22M 0
39476 22M 0
39477 22M 0
39478 22M 0
39479 22M 0
39480 22M 0
39481 22M 0
39482 22M 0
39483 22M 0
39484 22M 0
39485 22M 0
39486 22M 0
39487 22M 0
39488 22M 0
39489 22M 0
39490 22M 0
39491 22M 0
39492 22M 0
39521 22M 0
39522 22M 0
39523 22M 0
39524 22M 0
39525 22M 0
39526 22M 0
39527 22M 0
39528 22M 0
39529 22M 0
39530 22M 0
39531 22M 0
39532 22M 0
39533 22M 0
39534 22M 0
39535 22M 0
39536 22M 0
39537 22M 0
39538 22M 0
39539 22M 0
39540 22M 0
39541 22M 0
39542 22M 0
39543 22M 0
39544 22M 0
39545 22M 0