SELECT 
  category_id 
FROM 
  vi_categories 
WHERE 
  id_path REGEXP '(^|/)245(/|$)'

Query time 0.00013

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "vi_categories",
          "access_type": "ALL",
          "rows": 113,
          "filtered": 100,
          "attached_condition": "vi_categories.id_path regexp '(^|/)245(/|$)'"
        }
      }
    ]
  }
}

Result

category_id
245
246
247
248
249