title: SUBSTRING on an Inner Join in PostgreSQL
body: <p>One of my tables looks like the following- </p>
  
  <p><a href="https://i.stack.imgur.com/58n4j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/58n4j.png" alt="order table data"></a></p>
  
  <p>One of the columns ordertype in the table has data that always has 4 characters in the beginning and then the rest of the characters are separated by ; The length of the characters vary after the ;</p>
  
  <p>I am trying to use SUBSTRING to pull all the characters after the ; (semi-colon) regardless of their length. Also trying to do that for an INNER JOIN i am trying to execute. The substring in the INNER JOIN aims to pull the first 4 characters.</p>
  
  <p>For some reason my query errors out. Not sure if I am doing something wrong. </p>
  
  <p>Below is the sample query that I am trying to run- </p>
  
  <pre><code>SELECT
      ind_id,
      substring(ordertype FROM 6)
  FROM
      order_table
  INNER JOIN
      transaction_table
  ON
      transaction_table.fileid = order_table.substring(ordertype FROM 1 FOR 4;
  </code></pre>