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 (
    2423, 2424, 1257, 1258, 1259, 1260, 1261, 
    1262, 1263, 1264, 1228, 1236, 1252, 
    1253, 1254, 1209, 1169, 1170, 1171, 
    1172, 1173, 1174, 1175, 1176, 1177, 
    1178, 1179, 1180, 1181, 1182
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00089

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "110.61"
    },
    "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": 31,
            "rows_produced_per_join": 31,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (2423,2424,1257,1258,1259,1260,1261,1262,1263,1264,1228,1236,1252,1253,1254,1209,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182))",
            "cost_info": {
              "read_cost": "67.21",
              "eval_cost": "6.20",
              "prefix_cost": "73.41",
              "data_read_per_join": "496"
            },
            "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": 6,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "31.00",
              "eval_cost": "1.24",
              "prefix_cost": "110.61",
              "data_read_per_join": "16K"
            },
            "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
1169 100,117M
1170 100,117M
1171 100,117M
1172 10,117M
1173 10,134M
1174 135,10M
1175 130,11M
1176 130,11M
1177 130M
1178 130M
1179 131M
1180 131M
1181 130M
1182 130M
1209 366M
1228 140M
1236 106M
1252 366M
1253 366M
1254 366M
1257 134M
1258 137,135,134M
1259 134M
1260 106M
1261 106M
1262 134M
1263 134M
1264 145M
2423 193M
2424 193M