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 = 7211 
WHERE 
  cscart_products_categories.product_id IN (
    87640, 87876, 88506, 88507, 88510, 87987, 
    90828, 87632, 88561, 87637, 90827, 
    87938, 87941, 87997, 88026, 87781, 
    87882, 87988, 88047, 88048, 88050, 
    88051, 88052, 88053, 88054, 87990, 
    87961, 87875, 87937, 87950, 87959, 
    88798, 90826, 87952, 88004, 87998, 
    88000, 87881, 88031, 87948, 88702, 
    88749, 87945, 87942, 87964, 88029, 
    88018, 88021, 88799, 88006, 88013, 
    88015, 87972, 88703, 88750, 87944, 
    88595, 88154, 87874, 87783, 87880, 
    87873, 88797, 87782, 88701, 88748, 
    88596, 88594, 92893, 92894, 93002, 
    93003, 93004, 93005, 93006, 93007, 
    93008, 93009, 93010, 93011, 93012, 
    93013, 93014, 93015, 93341, 93342, 
    93343, 93344, 93345, 93346, 93347, 
    93348, 93349, 93350, 93351, 93352
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01762

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "137.81"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "11.90"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 208,
            "rows_produced_per_join": 8,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "20.72",
              "eval_cost": "0.83",
              "prefix_cost": "21.55",
              "data_read_per_join": "21K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "nuie_scalesta_net.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 117,
            "rows_produced_per_join": 11,
            "filtered": "1.22",
            "cost_info": {
              "read_cost": "2.33",
              "eval_cost": "1.19",
              "prefix_cost": "121.75",
              "data_read_per_join": "190"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (87640,87876,88506,88507,88510,87987,90828,87632,88561,87637,90827,87938,87941,87997,88026,87781,87882,87988,88047,88048,88050,88051,88052,88053,88054,87990,87961,87875,87937,87950,87959,88798,90826,87952,88004,87998,88000,87881,88031,87948,88702,88749,87945,87942,87964,88029,88018,88021,88799,88006,88013,88015,87972,88703,88750,87944,88595,88154,87874,87783,87880,87873,88797,87782,88701,88748,88596,88594,92893,92894,93002,93003,93004,93005,93006,93007,93008,93009,93010,93011,93012,93013,93014,93015,93341,93342,93343,93344,93345,93346,93347,93348,93349,93350,93351,93352))"
          }
        },
        {
          "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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 11,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.97",
              "eval_cost": "1.19",
              "prefix_cost": "125.91",
              "data_read_per_join": "190"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
87632 7210,7211,7214M 0
87637 7210,7211,7214M 0
87640 7210,7211,7214M 0
87781 7210,7211,7321M 0
87782 7210,7211,7321M 0
87783 7210,7211,7321M 0
87873 7208M,7241,7309,7346
87874 7208M,7241,7309,7346
87875 7208M,7241,7309,7346
87876 7208M,7241,7309,7346
87880 7208M,7241,7309,7346
87881 7208M,7241,7309,7346
87882 7208M,7241,7309,7346
87937 7259M,7345,7347
87938 7260M,7320
87941 7260M,7320
87942 7260M,7320
87944 7260M,7320
87945 7260M,7320
87948 7259M,7345,7347
87950 7259M,7345,7347
87952 7259M,7345,7347
87959 7260M,7320
87961 7260M,7320
87964 7260M,7320
87972 7260M,7320
87987 7259M,7345,7347
87988 7260M,7320
87990 7260M,7320
87997 7259M,7345,7347
87998 7260M,7320
88000 7260M,7320
88004 7259M,7345,7347
88006 7260M,7320
88013 7260M,7320
88015 7260M,7320
88018 7260M,7320
88021 7260M,7320
88026 7259M,7345,7347
88029 7259M,7345,7347
88031 7260M,7320
88047 7259M,7345,7347
88048 7259M,7345,7347
88050 7259M,7345,7347
88051 7259M,7345,7347
88052 7260M,7320
88053 7260M,7320
88054 7260M,7320
88154 7260M,7320
88506 7208M,7241,7309,7346
88507 7208M,7241,7309,7346
88510 7208M,7241,7309,7346
88561 7210,7211,7214M 0
88594 7210,7211,7282M 0
88595 7210,7211,7282M 0
88596 7210,7211,7282M 0
88701 7210,7211,7282M 0
88702 7210,7211,7282M 0
88703 7210,7211,7282M 0
88748 7210,7211,7282M 0
88749 7210,7211,7282M 0
88750 7210,7211,7282M 0
88797 7210,7211,7282M 0
88798 7210,7211,7282M 0
88799 7210,7211,7282M 0
90826 7208M,7241,7309,7346
90827 7208M,7241,7309,7346
90828 7208M,7241,7309,7346
92893 7208M,7241,7309,7346
92894 7208M,7241,7309,7346
93002 7208M,7241,7309,7346
93003 7208M,7241,7309,7346
93004 7208M,7241,7309,7346
93005 7208M,7241,7309,7346
93006 7208M,7241,7309,7346
93007 7208M,7241,7309,7346
93008 7208M,7241,7309,7346
93009 7208M,7241,7309,7346
93010 7208M,7241,7309,7346
93011 7208M,7241,7309,7346
93012 7208M,7241,7309,7346
93013 7208M,7241,7309,7346
93014 7208M,7241,7309,7346
93015 7208M,7241,7309,7346
93341 7208M,7241,7309,7346
93342 7208M,7241,7309,7346
93343 7208M,7241,7309,7346
93344 7208M,7241,7309,7346
93345 7208M,7241,7309,7346
93346 7208M,7241,7309,7346
93347 7208M,7241,7309,7346
93348 7208M,7241,7309,7346
93349 7208M,7241,7309,7346
93350 7208M,7241,7309,7346
93351 7208M,7241,7309,7346
93352 7208M,7241,7309,7346