开发者

How to get multi row data of one column to one row of one Column

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

For example 开发者_JAVA技巧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.


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.


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.)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜