Click here to Skip to main content
14,699,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here i have 1 field which contains coma separated value i want split it in query

i have value 1,2,3,4

i want to see like this

value1 value2 value3 value4
1 2 3 4

Like different fields

can any 1 help me please
adv thanx
AnnuBhai 30-Mar-13 3:16am
how ??????

I would use VB6 for such task. Anyway you may have a look at MySQL String Functions[^] (I guess iterating LOCATE and SUBSTR will do the job).
Maciej Los 30-Mar-13 8:19am
Why? MySQL database engine enable to create temporary tables and do many other things...
Please, see my answer.
I vote 4, because of good tip to use MySQL functions.
CPallini 30-Mar-13 9:27am
Because in VB6 you may do that in a single call.
Maciej Los 30-Mar-13 12:34pm
Single call (Split function) for each record fetched from database ;)

Please use the Below code, may it will help you. it is working fine in MS SQL.

select Replace(PhoneNo,',',' ') from EMP

Maciej Los 30-Mar-13 8:16am
It isn't correct answer. REPLACE function will replace some string with other string, but does not split string into columns.
Please, correct it or delete to prevent down-voting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900