SELECT 
  jmj_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      jmj_products_categories.link_type = "M", 
      CONCAT(
        jmj_products_categories.category_id, 
        "M"
      ), 
      jmj_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  jmj_products_categories 
  INNER JOIN jmj_categories ON jmj_categories.category_id = jmj_products_categories.category_id 
  AND jmj_categories.storefront_id IN (0, 1) 
  AND (
    jmj_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, jmj_categories.usergroup_ids) 
    OR FIND_IN_SET(1, jmj_categories.usergroup_ids)
  ) 
  AND jmj_categories.status IN ('A', 'H') 
  LEFT JOIN jmj_products_categories AS product_position_source ON jmj_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 2 
WHERE 
  jmj_products_categories.product_id IN (
    1705, 1730, 1654, 1662, 1713, 1733, 1682, 
    1675, 1702, 1728, 1719, 1511, 1517, 
    1523, 1526, 1645, 1647, 1670, 1659, 
    1656, 1723, 1668, 1679, 1696, 1731, 
    1699, 1732, 1707, 1697, 1735, 1695, 
    1686, 1734, 1721, 1729, 814, 816, 817, 
    818, 819, 820, 821, 822, 823, 825, 826, 
    827, 828, 895, 899, 901, 902, 813, 1460, 
    830, 868, 869, 870, 904, 905, 906, 907, 
    908, 909, 917, 920, 921, 922, 923, 924, 
    1105, 1109, 1110, 1111, 1112, 1113, 
    1114, 1115, 1116, 1117, 1118, 1119, 
    1120, 1122, 1123, 1150, 1151, 1152, 
    1059, 1060, 1032, 1033, 1034, 1035, 
    1036, 1037
  ) 
GROUP BY 
  jmj_products_categories.product_id

Query time 0.00662

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "71.66"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "5.59"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "jmj_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 120,
            "rows_produced_per_join": 4,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "28.46",
              "eval_cost": "0.96",
              "prefix_cost": "29.42",
              "data_read_per_join": "18K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`jmj_test`.`jmj_categories`.`storefront_id` in (0,1)) and ((`jmj_test`.`jmj_categories`.`usergroup_ids` = '') or find_in_set(0,`jmj_test`.`jmj_categories`.`usergroup_ids`) or find_in_set(1,`jmj_test`.`jmj_categories`.`usergroup_ids`)) and (`jmj_test`.`jmj_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "jmj_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "jmj_test.jmj_categories.category_id"
            ],
            "rows_examined_per_scan": 5,
            "rows_produced_per_join": 5,
            "filtered": "23.28",
            "index_condition": "(`jmj_test`.`jmj_products_categories`.`product_id` in (1705,1730,1654,1662,1713,1733,1682,1675,1702,1728,1719,1511,1517,1523,1526,1645,1647,1670,1659,1656,1723,1668,1679,1696,1731,1699,1732,1707,1697,1735,1695,1686,1734,1721,1729,814,816,817,818,819,820,821,822,823,825,826,827,828,895,899,901,902,813,1460,830,868,869,870,904,905,906,907,908,909,917,920,921,922,923,924,1105,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1122,1123,1150,1151,1152,1059,1060,1032,1033,1034,1035,1036,1037))",
            "cost_info": {
              "read_cost": "25.15",
              "eval_cost": "1.12",
              "prefix_cost": "59.37",
              "data_read_per_join": "89"
            },
            "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",
              "jmj_test.jmj_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "5.59",
              "eval_cost": "1.12",
              "prefix_cost": "66.08",
              "data_read_per_join": "89"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
813 60M
814 60M
816 60M
817 60M
818 60M
819 60M
820 60M
821 60M
822 60M
823 60M
825 60M
826 60M
827 60M
828 60M
830 60M
868 60M
869 60M
870 60M
895 60M
899 60M
901 60M
902 60M
904 60M
905 60M
906 60M
907 60M
908 60M
909 60M
917 60M
920 60M
921 60M
922 60M
923 60M
924 60M
1032 41M
1033 41M
1034 41M
1035 41M
1036 41M
1037 41M
1059 40M
1060 40M
1105 60M
1109 60M
1110 60M
1111 60M
1112 60M
1113 60M
1114 60M
1115 60M
1116 60M
1117 60M
1118 60M
1119 60M
1120 60M
1122 60M
1123 60M
1150 60M
1151 60M
1152 60M
1460 60M
1511 31M
1517 31M
1523 32M
1526 32M
1645 33M
1647 34M
1654 35M
1656 37M
1659 38M
1662 39M
1668 41M
1670 40M
1675 43M
1679 44M
1682 42M
1686 47M
1695 48M
1696 49M
1697 51M
1699 50M
1702 53M
1705 54M
1707 57M
1713 59M
1719 55M
1721 56M
1723 58M
1728 60M
1729 61M
1730 62M
1731 63M
1732 64M
1733 65M
1734 66M
1735 52M