Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate multiple name from one column

Status
Not open for further replies.

TheLazyPig

Programmer
Sep 26, 2019
95
PH
Hi!

I have a column "character" that contains multiple names

Screenshot_2022-08-30_120053_qct1ms.png


The result should be...
thelaypig / thelaxypig / thelazypig


Thanks for the replies!
 
Not 100% sure 'character' is a good field name... but

Code:
SELECT MYTABLE
INDEX ON CHARACTER TAG CHARACTER
GO TOP
m.KEY = MYTABLE.CHARACTER+"_"
m.STRING = ""
DO WHILE .NOT. EOF()
	IF MYTABLE.CHARACTER <> m.KEY
		m.KEY = MYTABLE.CHARACTER
		m.STRING = m.STRING +IIF(LEN(m.STRING)>0,"/","")+ m.KEY
	ENDIF
	SKIP
ENDDO
? m.STRING

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Code:
#Define SEPARATOR " / "
Local Arrray laCharacters[1]
Local lcList, lnI
lcList = ""
Select Distinct character From thetable Order By character Into Array laCharacters
For lnI = 1 To _Tally
   lcList = lcList + SEPARATOR + Alltrim(laCharacters[lnI])
Endfor
lcList = Substr(lcList,Len(SEPARATOR)+1)
? lcList && or do whatever you need with it



Chriss
 
Hi,

Something like

Code:
local lcString as Character

lcString = ""

select cCharacter from YourTable group by 1 into cursor csrTable

select csrTable

scan 

[indent]lcString = lcString + alltrim(csrTable.cCharacter) + " / "[/indent]

endscan

lcstring = substr(lcString, 1, len(lcString) - 3)

hth

MarK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top