title: Substring each row of a column in mySQL
body: <p>I have a table with a column called menu_name that contains a string like "one|two|three|four|something"</p>
  
  <p>I want to write a one time script that will remove everything after and including the last |</p>
  
  <p>So the final value would be "one|two|three|four"</p>
  
  <p>If there is no | in the cell, i.e "something" then I want to set the string to ""</p>
  
  <p>Thanks!</p>
  
  <p>Thanks to Nanhe Kumar for getting me close, here's the final command:  </p>
  
  <pre><code>UPDATE reports SET menu_name = SUBSTRING(menu_name,1,POSITION(substring_index(menu_name,'|',-1) IN menu_name)-2)
  </code></pre>