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 = 361 
WHERE 
  cscart_products_categories.product_id IN (
    1964, 434, 383, 1927, 435, 419, 403, 324, 
    1965, 440, 1966, 431, 1928, 1973, 1968, 
    1963, 327, 1934, 385, 405, 413, 1970, 
    1937, 433
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00593

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "169.07"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "13.93"
      },
      "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": 13,
            "filtered": "15.14",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (1964,434,383,1927,435,419,403,324,1965,440,1966,431,1928,1973,1968,1963,327,1934,385,405,413,1970,1937,433))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "2.79",
              "prefix_cost": "138.42",
              "data_read_per_join": "222"
            },
            "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": 13,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "13.93",
              "eval_cost": "2.79",
              "prefix_cost": "155.14",
              "data_read_per_join": "222"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
324 392,361,338M,396,353,355,358,351,360,391,395,393,354,368,363,390,357,350,359,349,340,362,394,388,352,356 0
327 376,372,369,362,352,356,378,375,381,386,374,371,361,379,382,370,385,353,355,358,351,384,360,380,354,377,373,363,357,350,359,349M,383 0
383 340,339,350,343,359,349,345,337M,376,372,362,352,356,378,375,381,386,338,374,371,361,341,370,385,353,355,358,351,384,344,360,368,342,354,377,347,373,363,357 0
385 347,394,373,388,363,357,340,369,339,350,343,359,392,349,345,337M,376,372,396,362,352,356,378,375,338,374,391,371,361,395,393,341,370,353,355,358,351,344,360,390,368,342,354,377 0
403 394,388,363,359M,392,362,361,395,393,360,368 0
405 342,360,354,377,368,347,373,357,340,369,339,394,350,343,388,363,349,345,337M,376,372,396,359,392,352,356,378,375,338,362,374,391,371,341,370,353,355,358,351,361,395,344,390,393 0
413 353,355,358,351,361,344,342,360,354,377,368,373,357,340,369,339,350,343,363,349,345,337M,376,372,359,352,356,378,375,338,362,374,371,341,370 0
419 395,390,393,341,353,355,358,351,361,344,342,360,354,368,389,394,388,357,340,396,339,350,343,392,363,349,345,337M,391,359,352,356,338,362 0
431 359,352,356,338,362,395,390,393,341,353,355,358,351,361,344,342,360,354,368,394,388,357,396,339,350,343,392,363,349,345,337M,391 0
433 363,359M,362,361,360,368 0
434 350,343,349,345,337M,383,363,352,356,338,347,359,362,341,381,386,353,355,358,379,382,351,344,380,385,361,342,384,354,340,360,357,368,339 0
435 392,360,368,391,349M,383,363,352,395,390,393,359,362,381,386,379,382,351,380,385,394,361,388,384,396 0
440 361,388,371,396,370,392,360,368,391,377,363,373,395,390,393,359M,369,362,376,372,375,374,394 0
1927 339,374,361M,350,345,337,370,349,338,391,377,353,358,363,390,359,369,379,351,378,362,340 0
1928 378,362,339,374,361M,350,345,370,349,338,391,395,381,390,359,369,379 0
1934 384,390,340,359,369,379,394,362,396,360,356,337,339,374,361M,350,352,345,370,355,349,373,344,338,377,391,358,363,342,395,354,381,372 0
1937 342,395,375,354,357,381,372,343,388,378,371,384,390,340,359,369,379,394,392,362,368,396,347,360,356,337,339,341,374,361M,350,352,345,393,370,386,353,355,382,349,373,344,338,377,391,358,376,363,351,380,385 0
1963 338,377,363,381,388,378,340,359,369,379,362,360,337,339,361M,350,352,370,349 0
1964 370,349,338,377,363,381,378,368,340,359,369,379,362,360,337,339,361M 0
1965 337,339,361M,370,349,338,377,363,381,368,340,359,369,379,362,352,360 0
1966 362,352,360,337,339,361M,370,349,338,377,363,381,368,340,359,369,379 0
1968 340,359,369,379,362,352,360,337,339,361M,370,349,338,363,381,350 0
1970 368,381,350,340,359,369,379,362,352,360,337,339,361M,377,370,349,338,363 0
1973 363,368,381,340,359,369,379,362,352,360,337,339,361M,377,370,349,338 0