SELECT 
  a.category_id 
FROM 
  cscart_categories as a 
  LEFT JOIN cscart_categories as b ON b.category_id IN (6340) 
WHERE 
  a.id_path LIKE CONCAT(b.id_path, '/%')

Query time 0.00425

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1494.60"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "b",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY",
            "p_category_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.20",
            "prefix_cost": "0.00",
            "data_read_per_join": "5K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      },
      {
        "table": {
          "table_name": "a",
          "access_type": "index",
          "key": "id_path",
          "used_key_parts": [
            "id_path"
          ],
          "key_length": "767",
          "rows_examined_per_scan": 6988,
          "rows_produced_per_join": 776,
          "filtered": "11.11",
          "using_index": true,
          "cost_info": {
            "read_cost": "97.00",
            "eval_cost": "155.27",
            "prefix_cost": "1494.60",
            "data_read_per_join": "4M"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ],
          "attached_condition": "(`webmarco`.`a`.`id_path` like <cache>(concat('6328/6340','/%')))"
        }
      }
    ]
  }
}

Result

category_id
6379
6425
6544
6581
6615
6664
6703
6761
6795
6827
6847
6967
7003
7059
7090
7119
7150
7182
7237
7268
7287
7355
7395
7470
7476
7540
7541
7543
7545
7548
7551
7554
7558
7575
7581
9033
9035
7668
7678
7683
7713
7717
7721
7728
7735
7742
7747
7768
7754
7783
7798
7802
7831
7917
7948
7955
7965
8074
8076
8099
8129
8175
8178
8184
8190
8198
8130
8136
6471
6504
6538
6563
6594
6628
6663
6689
6731
6851
6884
6914
9037
9038
9040
9041
9042
9043
9044
9045
9046
9047
9048
9050
9051
9052
9053
9054
9055
9057
9058
9059
9060
9061
9062
9063
9064
9065
6483
6500
6525
6545
6560
6591
6622
6665
6704
6767
6798
6860
6907
6960
6997
7021
7075
7106
7133
7174
7198
7220
7276
7292
7313
7335
7367
7388
7455
7460
7466
7474
7479
7556
7562
7570
7714
7720
7730
7800
7816
7836
8143
7850
6964
7009
7060
7102
7142
7187
7279
7312
7358
7393
7458
7467
7542
7547
7552
7565
7574
7586
7597
7610
7619
7632
7637
7646
7656
7247
7264
7282
7294
7310
7322
7341
7360
7376
7389
7399
7463
7468
7473
7477
7481
9066
9067
9068
9069
9070
9071
9072
9073
7620
9078
9079
9080
9081
7633
7644
9082
9083
9074
9075
9076
9077