I need to get data in multiple row of one column.
For example 开发者_JAVA技巧data from that format
ID Interest
- Sports
- Cooking
- Movie
- Reading
to that format
ID Interest
- Sports,Cooking
- 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.
精彩评论