Connecting Tech Pros Worldwide Help | Site Map

Concatenate multiple rows into one string

  #1  
Old November 13th, 2005, 12:57 AM
Smythe32
Guest
 
Posts: n/a
Hi,

I have the following table:

Project Name email_addr
happy jane.smith@happy.com
happy john.smith@lappy.com
happy mary.smith@happy.com
sad john.smith@lappy.com
paper mary.smith@happy.com
paper joy.smith@happy.com

What I would like to end up with is if I select project happy is:

jane.smith@happy.com;john.smith@lapp... th@happy.com

Any help would be greatly appreciated.

Thanks
  #2  
Old November 13th, 2005, 12:57 AM
Tom van Stiphout
Guest
 
Posts: n/a

re: Concatenate multiple rows into one string


On 18 Jun 2004 07:08:47 -0700, Smythe32@aol.com (Smythe32) wrote:

You'll have to do that with a recordset: open a recordset on a query
that pulls the right rows, then loop over it, and for each row add the
email address and a semicolon to a string variable. At the very end
remove the last semicolon.

-Tom.

[color=blue]
>Hi,
>
>I have the following table:
>
>Project Name email_addr
>happy jane.smith@happy.com
>happy john.smith@lappy.com
>happy mary.smith@happy.com
>sad john.smith@lappy.com
>paper mary.smith@happy.com
>paper joy.smith@happy.com
>
>What I would like to end up with is if I select project happy is:
>
>jane.smith@happy.com;john.smith@lappy.com;mary.sm ith@happy.com
>
>Any help would be greatly appreciated.
>
>Thanks[/color]

  #3  
Old November 13th, 2005, 12:58 AM
Pieter Linden
Guest
 
Posts: n/a

re: Concatenate multiple rows into one string


Tom van Stiphout <tom7744@no.spam.cox.net> wrote in message news:<57v5d0hmi8t1i82fpj9js86arojfilhaj6@4ax.com>. ..[color=blue]
> On 18 Jun 2004 07:08:47 -0700, Smythe32@aol.com (Smythe32) wrote:
>
> You'll have to do that with a recordset: open a recordset on a query
> that pulls the right rows, then loop over it, and for each row add the
> email address and a semicolon to a string variable. At the very end
> remove the last semicolon.
>
> -Tom.
>[/color]
There's an example of this here:
http://www.mvps.org/access/modules/mdl0004.htm
or here..
http://www.mvps.org/access/modules/mdl0008.htm
  #4  
Old November 13th, 2005, 01:53 AM
Smythe32
Guest
 
Posts: n/a

re: Concatenate multiple rows into one string


pietlinden@hotmail.com (Pieter Linden) wrote in message news:<bf31e41b.0406181435.515eae4@posting.google.c om>...[color=blue]
> Tom van Stiphout <tom7744@no.spam.cox.net> wrote in message news:<57v5d0hmi8t1i82fpj9js86arojfilhaj6@4ax.com>. ..[color=green]
> > On 18 Jun 2004 07:08:47 -0700, Smythe32@aol.com (Smythe32) wrote:
> >
> > You'll have to do that with a recordset: open a recordset on a query
> > that pulls the right rows, then loop over it, and for each row add the
> > email address and a semicolon to a string variable. At the very end
> > remove the last semicolon.
> >
> > -Tom.
> >[/color]
> There's an example of this here:
> http://www.mvps.org/access/modules/mdl0004.htm
> or here..
> http://www.mvps.org/access/modules/mdl0008.htm[/color]
I am unable to get this code to work. I think it has something to do
with I am looking at a string instead of a long.
  #5  
Old November 13th, 2005, 01:53 AM
Pieter Linden
Guest
 
Posts: n/a

re: Concatenate multiple rows into one string


Smythe32@aol.com (Smythe32) wrote in message news:<7f494502.0407091004.3956cd9b@posting.google. com>...[color=blue]
> pietlinden@hotmail.com (Pieter Linden) wrote in message news:<bf31e41b.0406181435.515eae4@posting.google.c om>...[color=green]
> > Tom van Stiphout <tom7744@no.spam.cox.net> wrote in message news:<57v5d0hmi8t1i82fpj9js86arojfilhaj6@4ax.com>. ..[color=darkred]
> > > On 18 Jun 2004 07:08:47 -0700, Smythe32@aol.com (Smythe32) wrote:
> > >
> > > You'll have to do that with a recordset: open a recordset on a query
> > > that pulls the right rows, then loop over it, and for each row add the
> > > email address and a semicolon to a string variable. At the very end
> > > remove the last semicolon.
> > >
> > > -Tom.
> > >[/color]
> > There's an example of this here:
> > http://www.mvps.org/access/modules/mdl0004.htm
> > or here..
> > http://www.mvps.org/access/modules/mdl0008.htm[/color]
> I am unable to get this code to work. I think it has something to do
> with I am looking at a string instead of a long.[/color]

Sounds like you're not passing the right value to the function - if
you specify that the field is a string, it should add the delimiters
for you. Or of course, you could do as Tom suggested...
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL to MS SQL Conversion ssnaik84 insights 0 October 11th, 2009 05:18 AM
Data type problems when concatenating fields. Whizzo answers 2 April 6th, 2009 01:32 PM
PL/Perl returning multiple rows Christopher Murtagh answers 22 November 12th, 2005 12:37 AM
executing sql code from text field or from multiple varchar(8000) rows in a table Rick Caborn answers 7 July 20th, 2005 06:13 AM