>Are you using VFP or SQL Server? If the later, which version. It is a piece of cake in SQL Server 2005 and up. In VFP you need to use custom function.
>
In other words,
function GetPESCAInfo
lparameter tcPesca
local lcResult
lnSelect = select()
if not used(GUIA)
use GUIA in 0 shared
endif
select * from GUIA where Pesca = m.tcPesca into cursor curTemp nofilter
scan
lcResult = m.lcResult + curTemp.SomeField + char(13)
endscan
use in select('curTemp')
select (m.lnSelect)
return m.lcResult
select P.*, GetPescaInfo(P.Pesca) from Pesca P
>>Hello.
>>
>>I work in a shrimp plant. Each day several trucks bring shrimp to the plant, the document each truck has to declare the amount of shrimp that is carrying si called GUIA. Usually we send a group of 3 to 4 trucks to a supplier, that group is organized with a document called PESCA.
>>
>>The table PESCA has a relation one to many with table GUIA. The output that i'm trying to show in the report is like this:
>>
>>Pesca: 520 (Guias: 4777 4778 4780)
>>
>>I don't know how to put three or four lines of GUIA into one single string.
>>
>>this is part of the sql instruction I'm using
>>
>>SELECT pes.Pesca, gu.Guia, .....
>>FROM lg_PescaC as pes ;
>>LEFT JOIN lg_Guia as gu ON pes.Pesca = gu.Pesca
>>
>>I should replace gu.Guia with a function, but don't know how to write it using only sql.
If it's not broken, fix it until it is.
My Blog