Jump to content


Photo

help with data output


  • Please log in to reply
1 reply to this topic

#1 jag

jag
  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationCalifornia

Posted 23 June 2003 - 01:25 AM

i\'m stuck on a data output problem. i\'m accessing a mysql database and retrieving all the row data. there are 3 fields - UID, SID, Answer

i\'m connecting and getting the data just fine. the problem is that there are multiple rows with the same UID and the data prints just like that. here\'s a sample:

83332091781424;2;felwick01
83332091781424;2;x
83332091781424;2;N1
83332091781424;2;N1
83332091781424;2;N1
83332091781424;2;N2
39808168103209171;2;felwick02
39808168103209171;2;x
39808168103209171;2;N2
39808168103209171;2;N1
39808168103209171;2;N4
39808168103209171;2;N6


what i need is only 1 instance of the UID, 1 instance of the SID, and then all the Answer field for each UID printed in a continuous row. example -

83332091781424;2;felwick01;x;N1;N1;N1;N2
39808168103209171;2;felwick02;x;N2;N1;N4;N6

any help would be *greatly* appreciated!

#2 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 23 June 2003 - 07:33 AM

Hi,

This can NOT be done in sql, since you want a variable number of rows returned and printed on one line.... It\'s a LOT easier to parse your output in php, and return what you want. (Or any other language, perl, basic, fortran whatever... )

On each new line>
while grab line {

if UID = UID above, nothing ELSE print UID
if SID = SID above, nothing ELSE print SID
print field3;

}

will do it, format to any language...

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users