MySQL Forums
Forum List  »  Quality Assurance

Re: How to Split value in Varcahar field
Posted by: John H. Embretsen
Date: April 05, 2011 04:59AM

Praveen,

Using the TRIM function should do the trick.

For example, consider the following table:

mysql> SELECT * FROM t1;
+------------------+
| SenderCompID     |
+------------------+
| SenderCompID(49) |
| AnotherID(47)    |
+------------------+
2 rows in set (0.00 sec)

Then this query should give you the separated values:

mysql> SELECT SUBSTRING_INDEX(SenderCompID, '(', 1) AS value1, TRIM(TRAILING ')' FROM SUBSTRING_INDEX(SenderCompID, '(', -1)) AS value2 FROM t1;
+--------------+--------+
| value1       | value2 |
+--------------+--------+
| SenderCompID | 49     |
| AnotherID    | 47     |
+--------------+--------+
2 rows in set (0.00 sec)


--
John

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to Split value in Varcahar field
4866
April 05, 2011 04:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.