|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Converting Fields into Rows in a table
Does anybody know how to add the values of several fields of one table into one field in another table. it's better to say I need to create a table with column Month and put the values from the columns January, February, march etc from another table.
Thank-you in advance for any answer. |
|
#2
|
||||
|
||||
|
Are you talking about a lookup table? I'm not sure I understand exactly what you want to do.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
No, I'm talking not about a lookup tables, all I need is to make rows from fields. I have a table with 12 fields (Jan, Feb,Mar...Dec) with a value in the evry column. So 12 fields and one row. I need to create a table with just two fields (e.g. Month and Value) and put the Jan, Feb etc into the Month Field and their values into the Value field. It's possible to make a query for every month and value. But maybe there is anything simplier?
Thank-you |
|
#4
|
||||
|
||||
|
Just reenter the data. You've spent more time describing the problem than you would have manually entering the data.
|
|
#5
|
|||
|
|||
|
I wish it was so easy. I just can't reenter huge tables with hundreds of fields every time. I can' t believe there is no way to do that automatically. I'm really stuck. Just don't know what to do.
|
|
#6
|
||||
|
||||
|
Wait, maybe you need to explain your problem more clearly. I understood you to be saying that you had one row of twelve columns (the months) that you wanted to reconfigure to be twelve rows of two columns. In that case, simply building the new table by hand would be easy. But you're talking about huge tables and hundreds of fields. There's been a disconnect somewhere. Can you provide a clearer explanation of what you're wanting to do? What're these huge tables?
|
|
#7
|
|||
|
|||
|
Same problem
Hi,
I've the same problem with a dynamic data. My case is as follows: I've one table with the following data Key Val1 Val2 Val3 ---- ---- ----- ---- k1 v1 v2 v3 And I want to retreive data as follows: Key Value ---- ----- k1 v1 k1 v2 k1 v3 Is this possible? |
|
#8
|
||||
|
||||
|
Mai, what you'll need to do (and maybe this answers the original question as well) is to create the new table, do a select from the original table, and then programmatically reconfigure the data format. Using the programming language of your choice, for each row, you'll iterate over the columns, and for each column, insert the first column and the current column values into the new table. To my knowledge, there's no way to do anything like this without writing a little program to handle it.
|
|
#9
|
|||
|
|||
|
Thanks dhouston.
I thought of doing it programatically, I just wanted to be sure it can't be done with SQL statement directly. |
|
#10
|
|||
|
|||
|
Hi,
I found some way to do what "Gisash" needs to do. After many searches in books online, I found an operator, "UNION", used to combine the results of two or more queries into a single result set consisting of all the rows belonging to all queries in the union. So for my previuos exapmle: Key Val1 Val2 Val3 ---- ---- ----- ---- k1 v1 v2 v3 The following query: Select Key, Val1 as Value From myTable UNION Select Key, Val2 From myTable UNION Select Key, Val3 From myTable Gives the following result: Key Value ---- ----- k1 v1 k1 v2 k1 v3 Please try it and tell me the results. |
|
#11
|
|||
|
|||
|
Mai,
I was having this same issue and, after trying some keyword combos in google, I came across this thread conversation. Your suggestion has aided me in solving my problem very quickly rather than me having to spend considerable amount of time figuring the approach out on my own. Thanks so much! Quote:
|
|
#12
|
|||
|
|||
|
Thanks
Ya it worked out.
Thanks a lot. Manish |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Converting Fields into Rows in a table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|