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.company_id = 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 = 362 
WHERE 
  cscart_products_categories.product_id IN (
    421, 443, 1971, 1959, 1930, 1960, 321, 
    436, 438, 437, 1961, 1931, 381, 1529, 
    2001, 1465, 1932, 1962, 1933, 1935, 
    1958, 428, 406, 439, 390, 1969, 398, 
    1964, 434, 383, 1927, 435, 419, 403, 
    324, 1965, 440, 1966, 431, 1928, 1973, 
    1968, 1963, 327, 1934, 2000, 385, 405, 
    413, 1970, 1937, 433, 414, 407, 402, 
    1972, 388, 1974, 442, 1956, 1936, 416, 
    326, 441, 1957
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.02626

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "219.13"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "36.69"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 115,
            "rows_produced_per_join": 2,
            "filtered": "2.00",
            "cost_info": {
              "read_cost": "27.56",
              "eval_cost": "0.46",
              "prefix_cost": "28.02",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "company_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`eshopuga_upgr_4122`.`cscart_categories`.`company_id` = 1) and ((`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`eshopuga_upgr_4122`.`cscart_categories`.`usergroup_ids`)) and (`eshopuga_upgr_4122`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "eshopuga_upgr_4122.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 36,
            "filtered": "39.88",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,1959,1930,1960,321,436,438,437,1961,1931,381,1529,2001,1465,1932,1962,1933,1935,1958,428,406,439,390,1969,398,1964,434,383,1927,435,419,403,324,1965,440,1966,431,1928,1973,1968,1963,327,1934,2000,385,405,413,1970,1937,433,414,407,402,1972,388,1974,442,1956,1936,416,326,441,1957))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "7.34",
              "prefix_cost": "138.42",
              "data_read_per_join": "586"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "eshopuga_upgr_4122.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 36,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "36.69",
              "eval_cost": "7.34",
              "prefix_cost": "182.45",
              "data_read_per_join": "586"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
321 359,362,349M 0
324 340,396,394,349,388,390,361,357,353,358,355,360,338M,359,350,351,368,392,362,363,393,356,352,354,391,395 0
326 352,354,383,381,391,395,396,374,382,394,369,349M,388,390,361,357,353,358,355,360,370,373,359,350,351,378,385,389,375,376,368,384,386,392,362,363,377,380,393,356,371,372,379 0
327 377,380,356,371,372,379,352,354,383,381,374,382,369,349M,361,357,353,358,355,360,370,373,359,350,351,378,385,375,376,384,386,362,363 0
381 375,376,384,386,362,363,340,341,380,342,356,371,372,379,352,339,354,383,381,344,338,374,382,349,361,337M,357,353,343,358,355,360,370,373,359,350,351,378,385,345,347 0
383 350,351,378,385,345,347,375,377,376,384,386,362,363,340,341,342,356,371,372,352,339,354,381,344,338,374,349,361,337M,357,353,343,358,355,360,370,373,368,359 0
385 343,358,355,360,370,393,373,368,359,350,351,378,345,347,391,395,375,396,377,376,394,388,390,362,363,340,341,369,342,356,371,372,352,339,354,344,338,374,349,361,337M,357,392,353 0
388 349,361,337M,357,353,343,358,355,360,385,368,359,350,351,380,345,347,384,386,379,383,362,363,340,341,382,342,356,381,352,339,354,344,338 0
390 344,338,392,349,361,337M,393,357,353,343,358,355,360,368,391,395,359,350,396,351,394,345,347,388,390,362,363,340,341,342,356,352,339,354 0
398 342,356,352,339,354,344,338,392,349,361,337M,393,357,353,343,358,355,360,368,391,395,359,350,396,351,394,345,347,388,390,389,362,363,340,341 0
402 362,363,340,341,342,356,352,339,354,344,338,392,349,361,337M,393,357,353,343,358,355,360,368,391,395,359,350,396,351,394,345,347,388,390 0
403 394,388,362,363,392,361,393,360,368,395,359M 0
405 360,345,347,368,390,395,359,394,388,370,340,373,341,342,356,362,363,378,352,339,354,375,377,376,344,338,349,337M,369,357,371,392,353,372,343,358,355,361,393,391,350,396,351,374 0
406 361,393,391,350,396,351,360,345,347,368,390,395,359,394,388,340,341,342,356,362,363,352,339,354,344,338,349,337M,357,392,353,343,358,355 0
407 337M,357,392,353,343,358,355,361,393,391,350,396,351,360,345,347,368,390,395,359,385,394,388,380,340,384,386,341,379,342,356,362,363,383,352,339,354,382,344,338,381,349 0
413 344,338,349,374,337M,357,353,343,358,355,361,370,350,373,351,360,345,368,359,378,375,377,376,340,341,342,356,362,363,369,371,352,339,354,372 0
414 362,363,369,371,352,339,354,372,344,338,349,374,337M,357,353,343,358,355,361,370,350,373,351,360,345,368,359,378,375,377,376,340,341,342,356 0
416 340,341,342,356,362,363,392,352,339,354,344,393,338,391,396,349,337M,357,390,395,353,343,358,355,394,361,388,350,351,360,345,368,359 0
419 359,340,341,342,356,362,363,392,352,339,354,344,393,338,391,396,349,337M,357,390,395,353,343,358,355,394,361,388,350,351,360,389,345,368 0
421 388,350,351,360,345,368,359,340,341,342,356,362,363,392,352,339,354,344,393,338,391,396,349,337M,357,390,395,353,343,358,355,394,361 0
428 390,395,353,343,358,355,394,361,388,350,351,360,345,368,359,347,340,341,342,356,362,363,392,352,339,354,344,393,338,391,396,349,337M,357 0
431 391,396,349,337M,357,390,395,353,343,358,355,394,361,388,350,351,360,345,368,359,341,342,356,362,363,392,352,339,354,344,393,338 0
433 361,360,368,359M,362,363 0
434 352,339,354,381,362,363,344,338,349,337M,357,353,343,358,355,350,351,385,361,345,347,340,380,360,384,386,368,379,359,341,383,342,356,382 0
435 392,383,393,382,391,352,381,396,362,363,390,395,349M,394,388,351,385,361,380,360,384,386,368,379,359 0
436 360,368,359M,362,363,361 0
437 361,360,368,359M,362,363 0
438 361,360,368,359M,362,363 0
439 341,386,384,342,379,339,354,369,383,371,372,344,338,382,352,361,381,337M,357,374,353,343,360,358,349,355,368,359,350,370,373,345,340,351,378,385,362,363,375,377,376 0
440 362,363,375,377,376,392,393,391,369,371,396,372,390,395,361,394,374,388,360,368,359M,370,373 0
441 351,370,380,356,341,362,363,384,342,339,354,383,344,338,382,352,369,371,381,372,337M,357,353,361,343,358,349,355,350,347,360,368,359,345,340 0
442 378,368,385,359M,373,370,380,386,379,375,377,376,362,363,384,383,382,369,371,381,372,374,361,360 0
443 360,368,359M,362,363,361 0
1465 345,361M,340,351,378,385,373,356,360,392,341,370,368,380,386,359,342,379,375,393,377,376,391,339,354,384,396,344,338,390,395,352,383,362,363,394,337,357,382,388,353,369,343,358,371,381,349,355,372,374,350,347 0
1529 349M,355,372,374,350,347,345,361,340,351,378,385,373,356,360,392,341,370,368,380,386,359,342,379,375,393,377,376,391,339,354,384,396,344,338,390,395,352,362,363,394,337,357,388,353,369,343,358,371,381 0
1927 337,353,369,358,349,374,350,345,361M,340,351,378,370,359,379,377,391,339,338,390,362,363 0
1928 338,390,362,381,369,349,374,350,345,361M,378,370,359,379,391,395,339 0
1930 379,388,391,395,339,363,355,337,338,390,353,362,381,369,349,356,350,340,351,341,345,375,361M,376,354,377,352,359 0
1931 359,371,372,379,388,391,395,339,363,337,338,390,353,362,381,385,374,369,360,349,380,342,350,340,396,345,361M,376 0
1932 345,394,377,352,359,379,388,391,339,338,390,362M,381,369,349,378,384,350 0
1933 396,361M,350,376,345,394,352,355,372,363,359,379,337,388,391,339,386,338,374,390,362,360,381,341,369,340,349,370 0
1934 369,340,349,370,396,361M,350,377,358,345,394,395,352,355,372,373,363,359,379,337,356,391,339,342,338,374,390,344,362,360,381,354,384 0
1935 342,338,374,390,344,362,360,381,384,369,340,376,349,361M,350,345,394,395,352,372,388,393,363,359,379,380,337,391,339 0
1936 391,339,338,374,390,362,360,381,370,384,396,369,377,376,349,361M,350,353,345,394,373,395,352,386,356,388,375,363,359,341,378,379,337 0
1937 356,388,375,363,359,357,341,354,378,379,337,343,342,391,344,339,347,371,338,374,390,362,340,360,381,370,358,384,396,369,377,376,349,392,355,368,385,361M,350,353,351,345,372,394,373,395,352,393,382,380,386 0
1956 362M 0
1957 352,363,359,379,337,339,331,338,340,360,381,370,369,362,377,349,368,361M 0
1958 361M,388,352,363,359,379,337,339,338,340,360,381,370,369,362,377,349,368 0
1959 362,377,349,368,361M,352,363,359,379,337,339,338,350,340,360,381,370,369 0
1960 340,360,381,370,369,362,377,349,378,368,361M,352,363,359,379,337,339,338 0
1961 350,338,340,360,381,370,369,362,377,349,378,368,361M,363,359,379,337,339 0
1962 363,359,379,337,339,350,338,340,360,381,388,370,369,362,377,390,349,361M,352 0
1963 363,359,379,337,339,350,338,340,360,381,388,370,378,369,362,377,349,361M,352 0
1964 363,359,379,337,339,338,368,340,360,381,370,378,369,362,377,349,361M 0
1965 361M,363,359,379,337,339,338,368,340,360,381,370,369,362,377,352,349 0
1966 369,362,377,352,349,361M,363,359,379,337,339,338,368,340,360,381,370 0
1968 338,340,360,381,370,369,362,352,349,361M,350,363,359,379,337,339 0
1969 337,368,339,338,340,360,381,370,369,362,352,349,361M,350,363,359,379 0
1970 363,359,379,337,368,339,377,338,340,360,381,370,369,362,352,349,361M,350 0
1971 363,359,379,337,368,339,377,338,340,360,381,370,369,362,352,349,361M,350 0
1972 361M,350,363,359,379,337,368,339,338,340,360,381,370,369,362,352,349 0
1973 369,362,352,349,361M,363,359,377,379,337,368,339,338,340,360,381,370 0
1974 340,360,381,370,369,362,352,349,350,361M,363,359,379,337,368,339,338 0
2000 338,369,391,362,349,396M,390,363 0
2001 363,338,369,391,362,349,396M,390 0