SELECT 
  q_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      q_products_categories.link_type = "M", 
      CONCAT(
        q_products_categories.category_id, 
        "M"
      ), 
      q_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  q_products_categories 
  INNER JOIN q_categories ON q_categories.category_id = q_products_categories.category_id 
  AND (
    q_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, q_categories.usergroup_ids) 
    OR FIND_IN_SET(1, q_categories.usergroup_ids)
  ) 
  AND q_categories.status IN ('A', 'H') 
WHERE 
  q_products_categories.product_id IN (
    32447, 32448, 32450, 32451, 32452, 32453, 
    32454, 32455, 32456, 32457, 32458, 
    32460, 32461, 32462, 32463, 32465, 
    32466, 32467, 32468, 32469, 32471, 
    32472, 32473, 32474, 32475, 32476, 
    32478, 32479, 32480, 32481, 32482, 
    32483
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00072

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "130.81"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "q_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 38,
            "rows_produced_per_join": 38,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (32447,32448,32450,32451,32452,32453,32454,32455,32456,32457,32458,32460,32461,32462,32463,32465,32466,32467,32468,32469,32471,32472,32473,32474,32475,32476,32478,32479,32480,32481,32482,32483))",
            "cost_info": {
              "read_cost": "77.61",
              "eval_cost": "7.60",
              "prefix_cost": "85.21",
              "data_read_per_join": "608"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "q_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "portal.q_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 7,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "38.00",
              "eval_cost": "1.52",
              "prefix_cost": "130.81",
              "data_read_per_join": "20K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "(((`portal`.`q_categories`.`usergroup_ids` = '') or find_in_set(0,`portal`.`q_categories`.`usergroup_ids`) or find_in_set(1,`portal`.`q_categories`.`usergroup_ids`)) and (`portal`.`q_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
32447 97M
32448 97M
32450 96M
32451 96M
32452 96M
32453 96M
32454 96M
32455 96M
32456 96M
32457 97M
32458 97M
32460 97M
32461 97M
32462 97M
32463 97M
32465 97M
32466 97M
32467 97M
32468 97M
32469 97M
32471 97M
32472 97M
32473 97M
32474 97M
32475 97M
32476 97M
32478 97M
32479 97M
32480 97M
32481 96M
32482 96M
32483 96M