Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Unanswered: MySQL Column Split

    I am hoping somebody can help me with a small problem i have.

    I am trying to split some data in one column in to two others.

    E.g. If i have a column called message in my table (smsmsg) I want to split the data in the message column into two others. The data needs to be split around an *.

    Sample data this is the message*other message

    In this example the text 'this is a message' will go into one column and the text 'other message' will go into another column.

    Any ideas, thanks in advance for any help.

    P.S. I am using MySQL 4.0.13

  2. #2
    Join Date
    Aug 2004
    Posts
    2
    I've managed to do it myself, if anybody is interested this is the code I used (I ended up splitting the message field in to two (msg1 and spmsg))

    Code:
    UPDATE smsmsg SET msg1=SUBSTRING(message, 1,POSITION('*' IN message)-1), spmsg=SUBSTRING(message, LENGTH(msg1)+1, 255);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •