Note to self: Although MySQL does not have a split / explode type function, it DOES have a built SUBSTRING_INDEX function that can be used in some circumstances. E.g. if you have a field with value '12345-right', you can get the left part with SUBSTRING_INDEX(value, '-', 1), and the right part with SUBSTRING_INDEX(value, '-', -1).
In general, I agree with Melchior Blausand's rant on StackOverflow: that I shouldn't be looking for explode, I should be looking at a better way to store my data. If you are reading this, think about storing differently rather than using a hack like this.
No comments:
Post a Comment