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.storefront_id IN (0, 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 = 265 
WHERE 
  cscart_products_categories.product_id IN (
    200, 201, 202, 271, 272, 273, 274, 275, 
    276, 277, 325, 326, 327, 328, 329, 330, 
    415, 416, 417, 418, 3616, 3617, 3618, 
    4080, 4081, 4082, 4083, 4084, 4085, 
    4086, 4156, 4157, 4158, 4159, 4160, 
    4161, 4162, 4209, 4210, 4211, 4212, 
    4213, 4214, 4215, 3102, 3110, 6670, 
    6685, 6698, 3095, 3101, 3108, 6683, 
    6697, 3099, 19, 20, 21, 3929, 3930, 3931, 
    3411, 3415, 3417, 6942, 3410, 3413, 
    3416, 6940, 3414, 6938, 6941, 6944, 
    3412, 6937, 6939, 6943, 6724, 3100, 
    3106, 3114, 3120, 3125, 3153, 3154, 
    6672, 6688, 6689, 6694, 6702, 6706, 
    6708, 6726, 6725, 3103, 3097
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00273

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "68.80"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.85"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 1,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "4.54",
              "eval_cost": "0.16",
              "prefix_cost": "4.70",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`gaseus`.`cscart_categories`.`storefront_id` in (0,1)) and ((`gaseus`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`gaseus`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`gaseus`.`cscart_categories`.`usergroup_ids`))) and (`gaseus`.`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": [
              "gaseus.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 110,
            "rows_produced_per_join": 1,
            "filtered": "1.05",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (200,201,202,271,272,273,274,275,276,277,325,326,327,328,329,330,415,416,417,418,3616,3617,3618,4080,4081,4082,4083,4084,4085,4086,4156,4157,4158,4159,4160,4161,4162,4209,4210,4211,4212,4213,4214,4215,3102,3110,6670,6685,6698,3095,3101,3108,6683,6697,3099,19,20,21,3929,3930,3931,3411,3415,3417,6942,3410,3413,3416,6940,3414,6938,6941,6944,3412,6937,6939,6943,6724,3100,3106,3114,3120,3125,3153,3154,6672,6688,6689,6694,6702,6706,6708,6726,6725,3103,3097))",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.19",
              "prefix_cost": "66.30",
              "data_read_per_join": "29"
            },
            "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",
              "gaseus.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.46",
              "eval_cost": "0.19",
              "prefix_cost": "66.95",
              "data_read_per_join": "29"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
19 273M
20 273M
21 273M
200 273M
201 273M
202 273M
271 273M
272 273M
273 273M
274 273M
275 273M
276 273M
277 273M
325 273M
326 273M
327 273M
328 273M
329 273M
330 273M
415 273M
416 273M
417 273M
418 273M
3095 273M
3097 273M
3099 273M
3100 273M
3101 273M
3102 273M
3103 273M
3106 273M
3108 273M
3110 273M
3114 273M
3120 273M
3125 273M
3153 273M
3154 273M
3410 288M
3411 288M
3412 282,267,288M
3413 288M
3414 282,267,288M
3415 288M
3416 288M
3417 288M
3616 273M
3617 273M
3618 273M
3929 273M
3930 273M
3931 273M
4080 273M
4081 273M
4082 273M
4083 273M
4084 273M
4085 273M
4086 273M
4156 273M
4157 273M
4158 273M
4159 273M
4160 273M
4161 273M
4162 273M
4209 273M
4210 273M
4211 273M
4212 273M
4213 273M
4214 273M
4215 273M
6670 273M
6672 273M
6683 273M
6685 273M
6688 273M
6689 273M
6694 273M
6697 273M
6698 273M
6702 273M
6706 273M
6708 273M
6724 273M
6725 273M
6726 273M
6937 282,267,288M
6938 282,267,288M
6939 282,267,288M
6940 288M
6941 282,267,288M
6942 288M
6943 282,267,288M
6944 282,267,288M