title: Get All Parents of Hierarchical Category in MySQL
body: <p>I have a table that looks like the following</p>
  
  <pre><code>cat_id  | name            |   parent_id |   Level
  -------------------------------------------------
  1         cat1                0             1
  2         subcat1             1             2
  3         subcat1-subcat      2             3
  </code></pre>
  
  <p>I am wondering what is the most efficient way to get the <strong>parent</strong> categories of <code>cat_id 3</code>, so my result set will look like this</p>
  
  <pre><code>cat_id  | name            |   parent_id |   Level
  --------------------------------------------------
  1         cat1                0             1
  2         subcat1             1             2
  </code></pre>