title: Selecting pages by path in MySQL/SQLite databases
body: <p>I am storing pages for websites in a 'pages' database table, they are referenced by their path (i.e. 'articles/my-first-blog-post'), I need to select all the children of a particular page, but without selecting grandchildren.</p>
  
  <p>So if I run:</p>
  
  <pre><code>SELECT * FROM pages WHERE path LIKE 'articles%'
  </code></pre>
  
  <p>I'll get pages with the following paths:</p>
  
  <pre>articles/one
  articles/two
  articles/two/more
  articles/three
  articles/three/more/even-more</pre>
  
  <p>I need to filter them (in the query) to just:</p>
  
  <pre>articles/one
  articles/two
  articles/three</pre>
  
  <p>Is there anyway to do something like:</p>
  
  <pre><code>SELECT * FROM pages WHERE path LIKE 'articles%' AND path NOT LIKE 'articles%/%'
  </code></pre>
  
  <p>Any ideas? Cheers.</p>