Return Multiple Rows In A String

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zergziad
    New Member
    • Mar 2008
    • 3

    Return Multiple Rows In A String

    Hi All,

    I need help on how to return the rows in one particular field as a string with comma separated in
    between those data. For example:

    Table A

    ID Name IsActive
    _______________ _______________ _________

    1 Amy 1
    2 Anne 0
    3 Del 0

    How do i return resultset like this :

    Amy(Active),Ann e,Del

    Can we use Concat function in this case?Really hope anyone can give some idea.
  • yasmine
    New Member
    • Feb 2008
    • 64

    #2
    Originally posted by zergziad
    Hi All,

    I need help on how to return the rows in one particular field as a string with comma separated in
    between those data. For example:

    Table A

    ID Name IsActive
    _______________ _______________ _________

    1 Amy 1
    2 Anne 0
    3 Del 0

    How do i return resultset like this :

    Amy(Active),Ann e,Del

    Can we use Concat function in this case?Really hope anyone can give some idea.


    Hi
    You can do this by 2 ways.

    1. use implode() function of php.
    2. use group_concat() function in mysql.

    your problem is already discussed here.
    Refer the thread Comma Separated which is in MySQL forum.

    Thanx n Regards
    Yas...

    Comment

    • zergziad
      New Member
      • Mar 2008
      • 3

      #3
      Originally posted by yasmine
      Hi
      You can do this by 2 ways.

      1. use implode() function of php.
      2. use group_concat() function in mysql.

      your problem is already discussed here.
      Refer the thread Comma Separated which is in MySQL forum.

      Thanx n Regards
      Yas...
      Hi Yas, thanx for the idea,my problem solved already. For your information,im using asp.net 2.0 not php and i've used to append character using stringbuilder function provided in asp.net (",)

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        GROUP_CONCAT() is a MySQL function.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by mwasif
          GROUP_CONCAT() is a MySQL function.
          And available only with MySql version 4.1 and above.

          Ronald

          Comment

          Working...