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 = 350 
WHERE 
  cscart_products_categories.product_id IN (
    421, 427, 408, 1971, 382, 418, 1959, 1930, 
    400, 424, 1961, 1931, 381, 1529, 1465, 
    1932, 1962, 1933, 1935, 428, 415, 391, 
    406, 329, 439, 390, 1969, 393, 394, 1929, 
    396, 397, 398, 399, 422, 434, 383, 412, 
    1927, 419
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01339

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "193.52"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "25.04"
      },
      "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": 25,
            "filtered": "27.22",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (421,427,408,1971,382,418,1959,1930,400,424,1961,1931,381,1529,1465,1932,1962,1933,1935,428,415,391,406,329,439,390,1969,393,394,1929,396,397,398,399,422,434,383,412,1927,419))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "5.01",
              "prefix_cost": "138.42",
              "data_read_per_join": "400"
            },
            "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": 25,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "25.04",
              "eval_cost": "5.01",
              "prefix_cost": "168.48",
              "data_read_per_join": "400"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
329 342,375,372,374,358,354,377,376,339,356,371,350,338,370,378,352,355,351,357,373,369,349M,353 0
381 373,384,349,385,353,344,361,343,363,342,375,372,380,382,374,360,358,354,345,341,359,376,362,339,356,383,371,350,340,379,381,347,338,370,378,352,355,386,351,337M,357 0
382 369,338,370,378,352,355,386,351,337M,357,373,384,349,385,353,344,343,342,375,372,382,377,374,358,354,345,341,376,339,356,383,371,350,340,379,381,347 0
383 371,350,340,381,347,338,370,378,352,355,386,351,337M,361,357,373,363,384,349,385,353,344,368,343,342,375,372,360,377,359,374,358,354,362,345,341,376,339,356 0
390 339,356,350,340,347,392,338,352,355,396,351,337M,361,357,390,363,349,353,344,393,368,343,342,360,395,359,388,358,354,362,345,341,391,394 0
391 354,345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342,358 0
393 379,358,371,369,354,381,345,341,370,378,380,339,356,386,373,350,340,384,382,385,347,338,375,372,352,355,377,351,337M,357,374,349,353,344,343,383,342,376 0
394 353,344,343,383,342,376,379,358,371,369,354,381,345,341,370,378,380,339,356,386,373,350,340,384,382,385,347,338,375,372,352,355,377,351,337M,357,374,349 0
396 352,355,377,351,337M,357,374,349,353,344,343,342,376,358,371,369,354,345,341,370,378,339,356,373,350,340,347,338,375,372 0
397 347,338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356,350,340 0
398 339,356,362,350,340,391,394,389,347,338,352,355,351,337M,357,349,392,353,344,343,396,342,361,390,363,393,368,358,354,360,395,345,341,359,388 0
399 345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342,358,354 0
400 358,354,345,341,339,356,350,340,347,338,352,355,351,337M,357,349,353,344,343,342 0
406 395,343,342,359,388,362,358,354,391,394,345,341,339,356,350,340,392,347,396,338,361,390,363,352,355,351,337M,357,393,368,349,353,344,360 0
408 357,349,375,353,344,372,343,377,342,383,374,358,379,354,376,345,341,381,371,369,339,356,380,386,350,340,370,384,347,378,382,385,338,373,352,355,351,337M 0
412 338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356,350,340,347 0
415 350,340,338,352,355,351,337M,357,349,353,344,343,342,358,354,345,341,339,356 0
418 373,339,356,350,340,375,372,377,338,352,355,374,351,337M,357,349,353,344,376,343,342,371,369,358,354,363,370,345,341,378 0
419 358,393,354,368,363,345,341,360,395,339,359,356,388,389,362,350,340,391,394,338,352,355,351,337M,357,349,353,344,392,343,342,396,361,390 0
421 396,361,390,358,393,354,368,363,345,341,360,395,339,359,356,388,362,350,340,391,394,338,352,355,351,337M,357,349,353,344,392,343,342 0
422 349,353,344,343,342,358,354,345,341,339,356,350,340,338,352,355,351,337M,357 0
424 352,355,351,337M,357,347,349,353,344,343,342,358,354,345,341,339,356,350,340,338 0
427 382,385,370,338,378,352,355,351,337M,373,357,347,349,353,344,375,383,343,372,342,377,379,374,358,354,381,345,341,376,380,386,339,356,371,369,384,350,340 0
428 339,356,392,350,340,396,361,390,338,393,352,355,368,351,337M,363,357,347,360,395,349,353,344,343,359,388,342,362,391,394,358,354,345,341 0
434 380,386,345,341,384,382,385,339,356,350,340,361,338,352,355,368,351,337M,383,363,357,347,360,349,353,344,379,343,359,342,362,381,358,354 0
439 381,371,369,358,354,386,345,341,370,384,378,382,385,339,373,350,340,361,375,372,338,377,352,355,368,351,337M,383,363,357,374,360,349,353,344,379,343,359,342,376,362 0
1465 379,343,359,342,376,362,380,381,371,369,392,358,354,386,396,356,345,341,390,370,384,378,382,385,393,339,373,350,340,395,361M,375,372,388,347,338,377,352,355,368,351,337,383,363,357,374,391,394,360,349,353,344 0
1529 368,351,337,363,357,374,391,394,360,349M,353,344,379,343,359,342,376,362,380,381,371,369,392,358,354,386,396,356,345,341,390,370,384,378,385,393,339,373,350,340,395,361,375,372,388,347,338,377,352,355 0
1927 361M,338,377,351,337,363,374,391,349,353,379,359,362,369,358,345,390,370,378,339,350,340 0
1929 388,350,352,338,377,337,363M,391,349,379,381,359,369,345,373,390,339 0
1930 345,375,390,340,339,355,361M,388,350,352,351,338,376,377,353,337,363,391,349,362,354,379,381,359,356,341,369,395 0
1931 369,372,395,345,390,340,360,339,361M,374,388,350,342,380,338,376,371,353,337,396,363,391,349,362,385,379,381,359 0
1932 369,394,345,390,352,339,388,350,377,338,384,391,349,362M,378,379,381,359 0
1933 391,349,362,379,381,359,372,355,369,394,340,360,361M,345,390,374,352,339,386,388,350,376,337,396,363,341,338,370 0
1935 338,391,349,362,395,379,381,344,359,372,369,394,340,342,360,380,361M,345,390,374,352,339,393,388,350,376,384,337,363 0
1959 350,370,337,363,368,338,349,362,379,381,359,369,340,360,377,361M,352,339 0
1961 339,378,350,370,337,363,368,338,349,362,379,381,359,369,340,360,377,361M 0
1962 388,340,360,377,352,361M,339,350,370,337,363,338,349,362,379,381,359,390,369 0
1969 369,340,360,352,361M,339,368,350,370,337,363,338,349,362,379,381,359 0
1971 362,379,381,359,377,369,340,360,352,361M,339,368,350,370,337,363,338,349 0