Combining Mulitple Records with Same Pri Key

MonkeyChico

Registered User.
Local time
Today, 05:59
Joined
May 11, 2010
Messages
18
I think this is a simple question, but I can't seem to find the answer. I have a table in which the key identifier of each record is a field called "PolicyID". The problem is the one policyID can have multiple record entries. I want to combine all the data into one record. Here's what I have:

PolicyID Year Class Limit
123 2005 2 $500
123 2006 1 $800
123 2006 3 $600
133 ...
133 ...
133 ...

I'd like to have something like this:
PolicyID Year1 Class1 Limit1 Year2 Class2 Limit2 Year3 Class3 Limit3
123 2005 2 $500 2006 1 $800 2006 3 $600

Ideas?

Thanks very much in advance.
 
I think this is a simple question, but I can't seem to find the answer. I have a table in which the key identifier of each record is a field called "PolicyID". The problem is the one policyID can have multiple record entries. I want to combine all the data into one record. Here's what I have:

PolicyID Year Class Limit
123 2005 2 $500
123 2006 1 $800
123 2006 3 $600
133 ...
133 ...
133 ...

I'd like to have something like this:
PolicyID Year1 Class1 Limit1 Year2 Class2 Limit2 Year3 Class3 Limit3
123 2005 2 $500 2006 1 $800 2006 3 $600

Ideas?

Thanks very much in advance.

If you are wanting to handle this in a query, here is one option:

Return a concatenated list of sub-record values

You will need to modify the above code to meet your needs.
 
That's not a primary key, that's a foreign key. In a database one record in one table should store information about one thing. Your proposal to create fields Year1, Year2, Year3 in the same table is exactly what your database 101 prof will tell you never to do.
Your data structure looks right as you've described it, but maybe you need to learn how to query that data to get the results you need.
Cheers,
 

Users who are viewing this thread

Back
Top Bottom