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

Query time 0.01231

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "214.31"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "34.50"
      },
      "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": 34,
            "filtered": "37.49",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,443,1971,1959,1960,436,438,437,1961,1931,381,1529,1465,1962,1933,1935,1958,428,406,439,390,1969,398,1964,434,383,435,419,403,324,1965,440,1966,431,1973,1968,1963,327,1934,385,405,413,1970,1937,433,414,407,402,1972,388,1974,442,1936,416,326,441,1957))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "6.90",
              "prefix_cost": "138.42",
              "data_read_per_join": "551"
            },
            "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": 34,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "34.50",
              "eval_cost": "6.90",
              "prefix_cost": "179.82",
              "data_read_per_join": "551"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

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