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.
Author |
Topic |
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2011-03-23 : 02:40:57
|
table2ID Name001 ABC002 XYZtable1ID 001002003..........In that case, how to get comma seperated name of table2 ?Based on some condition, I will get some ID of table1 and want to retreive comma seperated name from table2 .Thanks. |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2011-03-23 : 04:17:08
|
Can I use IN operator ? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2011-03-23 : 04:42:54
|
This returns 2rows (2 product numbers) and I wanted to make them as one comma seperated value . (Eg. product001,product002)SELECT productnumberFROM ProductbaseWHERE productid IN (select productid from invoicedetailbasewhere invoiceid = 'abcd' and productid is not null)quote: Originally posted by khtan not really sure what do you need. Probably this ?http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254 KH[spoiler]Time is always against us[/spoiler]
|
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-23 : 04:46:17
|
quote: Originally posted by kwikwisi This returns 2rows (2 product numbers) and I wanted to make them as one comma seperated value . (Eg. product001,product002)SELECT productnumberFROM ProductbaseWHERE productid IN (select productid from invoicedetailbasewhere invoiceid = 'abcd' and productid is not null)quote: Originally posted by khtan not really sure what do you need. Probably this ?http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254 KH[spoiler]Time is always against us[/spoiler]
Refer to the link. Use the for xml path method there KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|