title: How to get all the string before an empty space in postgres?
body: <p>So basically I need to get a part of the postcode string, all before an empty space</p>
  
  <p>my current query is </p>
  
  <pre><code>select postcode, left(postcode, length(postcode) - strpos(' ', postcode)) 
  from postcodetable
  </code></pre>
  
  <p>But it just doesn't return the post code correctly, example:
  1st column is <code>NW1 1AA</code>, 2nd column should just be <code>NW1</code> but instead it just repeats the first column</p>