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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN q_products_categories AS product_position_source ON q_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 168 
WHERE 
  q_products_categories.product_id IN (
    29282, 29283, 29314, 29341, 29690, 29694, 
    29702, 29799, 30319, 30339, 30770, 
    30781, 30782, 30783, 30787, 30794, 
    30799, 30815, 30860, 30873, 30876, 
    30899, 30911, 30920, 30931, 30937, 
    30939, 30943, 30957, 30972, 31015, 
    31045
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00096

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "168.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": 36,
            "rows_produced_per_join": 36,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (29282,29283,29314,29341,29690,29694,29702,29799,30319,30339,30770,30781,30782,30783,30787,30794,30799,30815,30860,30873,30876,30899,30911,30920,30931,30937,30939,30943,30957,30972,31015,31045))",
            "cost_info": {
              "read_cost": "75.21",
              "eval_cost": "7.20",
              "prefix_cost": "82.41",
              "data_read_per_join": "576"
            },
            "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",
              "portal.q_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 36,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "36.00",
              "eval_cost": "7.20",
              "prefix_cost": "125.61",
              "data_read_per_join": "576"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": "36.00",
              "eval_cost": "1.44",
              "prefix_cost": "168.81",
              "data_read_per_join": "19K"
            },
            "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 position
29282 180M
29283 183M
29314 183M
29341 169M
29690 183M
29694 183M
29702 168M 0
29799 529M
30319 188M
30339 529M
30770 179M
30781 183M
30782 529M
30783 183M
30787 183M
30794 529M
30799 183M
30815 529M
30860 183M
30873 183M
30876 180M
30899 183M
30911 183M
30920 183M
30931 183M
30937 183M
30939 529M
30943 183M
30957 183M
30972 180M
31015 177M
31045 518M