Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2004, 11:57 AM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Concatenate Data

How to Concatenate Data from the 'Many'
Side of a Relationship

I found this question in the archives but couldn't find the answer.

If anyone has the answer I would be eternally grateful


I have the following data in a 2 column table:

Column1 Column2
------------------ ------------------------
Beverages Products Chai
Beverages Products Chang
Beverages Products Chartreuseverte
Beverages Products Cote de Blaye
Beverages Products Guarana Fantastica
Condiments Products Aniseed Syrup
Condiments Products Chef
Condiments Products Anton's Cajun Seasoning
Condiments Products Chef Anton's Gumbo Mix
Condiments Products Genen Shouyu, Grandma's

Is there an easy way to concatenate values from column2 to show:

Column1 Column2
------------------ ------------------------
Beverages Products Chai, Chang, Chartreuseverte, Cote de Blaye, etc.
Condiments Products Aniseed Syrup, Chef, Anton's Cajun Seasoning, etc.=
 
Old March 31st, 2004, 12:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

There really isn't a 'good' way to do this, but see
http://p2p.wrox.com/topic.asp?TOPIC_ID=1787

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old March 31st, 2004, 12:59 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks for such a prompt response Jeff.

I'm a complete novice at this game. Would I be correct in assuming that, whereas this fix could work for SQL Server 2000, the code you suggest wouldn't work for MS Access?

Mike


Quote:
quote:Originally posted by Jeff Mason
 There really isn't a 'good' way to do this, but see
http://p2p.wrox.com/topic.asp?TOPIC_ID=1787

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old March 31st, 2004, 01:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

I haven't tried such a thing in Access, but I wouldn't be surprised if a similar approach couldn't be made to work. In fact, since Access allows er, access, to functions and variables defined "outside" of SQL statements, it might actually be easier to accomplish.

It's still wrong, though; the result of such a concatenation violates first normal form...

It is my opinion this is a presentation issue and not a query issue, so it should be handled at the client. The resultset is returned to client code as multiple rows, and the client manipulates them and combines them however it wants for display purposes.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old April 1st, 2004, 04:31 AM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again for the assistance. I'll persevere and advise how I progress.

Mike






Similar Threads
Thread Thread Starter Forum Replies Last Post
concatenate records davehodges Access 5 November 1st, 2007 10:13 AM
Concatenate Rows stonesbg ASP.NET 2.0 Basics 5 February 6th, 2007 06:12 PM
Hyperlink (Concatenate) JEHalm Excel VBA 1 January 11th, 2006 01:09 PM
Concatenate numbers fs22 Javascript 1 April 25th, 2004 06:51 AM
Concatenate 2 variables into one? cpopham Access VBA 2 December 9th, 2003 10:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.