• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

sql query help me

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table structure

MemberDetails
----------------
MembershipDetailsID PK
MembershipID FK
Benefits Varchar

A MembershipID can contain many benefits which can be added.

At the time of retrieval i want a query to fetch all the benefits for this MembershipID in a single record.

i.e in normal suitations my query to fetch benefits is as following...

select Benefits from MemberDetails where MembershipID=10;
here i will get mutiple records.

what i want is a single record with Benefits values as comma seperated.




can you help me regarding this sub-query? is this posibble?is this question
against the normalisation rules?

Thanks
[ March 30, 2007: Message edited by: sreenivas jeenor ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. It doesn't sound like you need to so anything in SQL here. Why don't you handle this in whichever application generated the query? There is no easy way to turn a result set into a single record without some programming logic. You could do it in a Stored Procedure, by iterating though your results set to generate another one by concatenating the results.
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul for your suggestion.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic