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 
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') 
WHERE 
  cscart_products_categories.product_id IN (436, 383, 384, 385, 387, 386) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00201

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "141.80"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "3.37"
      },
      "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": 3,
            "filtered": "3.67",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (436,383,384,385,387,386))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "0.67",
              "prefix_cost": "138.42",
              "data_read_per_join": "53"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
383 339,386,375,363,368,350,378,361,338,354,344,360,371,352,358,342,374,377,347,343,353,357,381,341,362,370,345,373,349,384,359,376,356,340,385,351,337M,355,372
384 351,337M,355,339,350,338,354,344,352,358,342,347,343,353,357,341,345,349,356,340
385 349,356,340,395,372,388,351,375,363,337M,368,378,396,361,355,339,390,350,360,338,371,391,354,374,344,377,352,358,392,342,362,347,370,343,393,373,353,357,341,359,376,369,394,345
386 353,357,341,345,349,356,340,351,337M,355,339,350,338,354,344,352,358,342,347,343
387 347,343,353,357,341,345,349,356,340,351,337M,355,339,350,338,354,344,352,358,342
436 359M,363,368,361,360,362