title: Mysql query to extract domains from urls
body: <p>sorry for my english</p>
  
  <p>i have this query to extract domain from urls</p>
  
  <pre><code>SELECT SUBSTRING(LEFT(url, LOCATE('/', url, 8) - 1), 8) AS domain...
  </code></pre>
  
  <p>it works only when the url is like www.google.com/something</p>
  
  <p>it doesn't work with urls like</p>
  
  <p>www.google.it (without trailing slash)</p>
  
  <p>www.google.it/abc/xzy/ (permalink)</p>
  
  <p>do you know how to solve it?</p>