tags:

views:

130

answers:

4

Hi friends,

I need to get data in multiple row of one column.

For example data from that format

ID Interest

  1. Sports
  2. Cooking
  3. Movie
  4. Reading

to that format

ID Interest

  1. Sports,Cooking
  2. Movie,Reading

I wonder that we can do that in MS Access sql. If anybody knows that, please help me on that.

A: 

This is nothing you should do in SQL and it's most likely not possible at all.

Merging the rows in your application code shouldn't be too hard.

ThiefMaster
Why are you downvoting this without leaving a comment? Do you really think something like that belongs into database code?
ThiefMaster
I think the original poster never provided enough information for these answers to be validated, including yours. I didn't down-vote your answer. I may DV the question though, since we're all hanging!
Smandoli
I downvoted it because categorical statements like "this is nothing you should do in SQL" are always incorrect. I don't know if it can or should be done in SQL, but it depends on the context. Also, I don't know who invented the restriction to doing it in SQL -- it's certainly not in the original question. If you mean that you should never denormalize, that's malarkey, too. No, you shouldn't *store* denormalized values, but NOBODY HAS SUGGESTED SUCH A THING. Now that I've thought it through, I wish I could give you 2 downvotes, your answer is so bad.
David-W-Fenton
A: 

This is called de-normalizing data. It may be acceptable for final reporting. Apparently some experts believe it's good for something, as seen here.

(Mind you, kevchadder's question is right on.)

Smandoli
A: 

Have you looked into the SQL Pivot operation? Take a look at this link: http://technet.microsoft.com/en-us/library/ms177410.aspx

Just noticed you're using access. Take a look at this article: http://www.blueclaw-db.com/accessquerysql/pivot_query.htm

Abe Miessler
+1  A: 

Take a look at Allen Browne's approach: Concatenate values from related records

As for the normalization argument, I'm not suggesting you store concatenated values. But if you want to join them together for display purposes (like a report or form), I don't think you're violating the rules of normalization.

HansUp