Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select query

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2008-03-26 : 10:03:51
Morning/Afternoon,

Have a table called tblproducts and a second table called tblcolour.

Now some of the products have many different colours, so when i run a select query and join the tables it returns many rows, with all coloums being the same apart from the colours field.

What i would like to do is return the results so that colour field gets return in its own coloum but the values are serpated with a comma. The number of colours can be different depending on product.

example:
Product Colour

Paint Red,Blue,Yellow
Pens Gold, Pink, Yellow, Purple
Been told that i can create a function to do and called when i need to run this select statement.

Hope you can help.

Regards Lee

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-26 : 10:19:47
See this: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-26 : 13:23:15
http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html
Go to Top of Page
   

- Advertisement -