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 (330, 331, 391, 390, 393, 389, 388) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00224

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "142.29"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "3.87"
      },
      "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": "4.20",
            "index_condition": "(`eshopuga_upgr_4122`.`cscart_products_categories`.`product_id` in (330,331,391,390,393,389,388))",
            "cost_info": {
              "read_cost": "92.00",
              "eval_cost": "0.77",
              "prefix_cost": "138.42",
              "data_read_per_join": "61"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        }
      ]
    }
  }
}

Result

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