Click here to Skip to main content
13,054,615 members (48,482 online)
Rate this:
Please Sign up or sign in to vote.
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
Posted 29-Mar-13 21:08pm
AnnuBhai 30-Mar-13 3:16am
how ??????
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 ;)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100