Skip to content

Instantly share code, notes, and snippets.

@audriusrudalevicius
Created September 10, 2012 13:24
Show Gist options
  • Save audriusrudalevicius/3690880 to your computer and use it in GitHub Desktop.
Save audriusrudalevicius/3690880 to your computer and use it in GitHub Desktop.
mysql explode
if(INSTR({string_or_var}, '-'), (REPLACE( SUBSTRING( SUBSTRING_INDEX( {string_or_var}, '-', 1 ) ,
LENGTH( SUBSTRING_INDEX( {string_or_var}, {string_or_var}, 1 -1 ) ) +1 ) , '-', '' )), '')
if(INSTR({string_or_var}, '-'), (REPLACE( SUBSTRING( SUBSTRING_INDEX( {string_or_var}, '-', 2 ) ,
LENGTH( SUBSTRING_INDEX( {string_or_var}, {string_or_var}, 2 -1 ) ) +1 ) , '-', '' )), '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment