If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL Column Split

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-04, 07:21
the-beast the-beast is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 08-13-04, 11:11
the-beast the-beast is offline
Registered User
 
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);
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On