Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 21st, 2004, 11:15 AM
Gisash Gisash is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 Gisash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old July 21st, 2004, 03:51 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #3  
Old July 22nd, 2004, 10:54 AM
Gisash Gisash is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 Gisash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old July 22nd, 2004, 01:26 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Just reenter the data. You've spent more time describing the problem than you would have manually entering the data.

Reply With Quote
  #5  
Old July 27th, 2004, 04:29 PM
Gisash Gisash is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 Gisash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old July 27th, 2004, 09:47 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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?

Reply With Quote
  #7  
Old July 28th, 2004, 04:19 AM
mai mai is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 mai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?


Reply With Quote
  #8  
Old July 28th, 2004, 07:07 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #9  
Old July 29th, 2004, 05:57 AM
mai mai is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 mai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks dhouston.
I thought of doing it programatically, I just wanted to be sure it can't be done with SQL statement directly.

Reply With Quote
  #10  
Old August 3rd, 2004, 03:50 AM
mai mai is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 mai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.


Reply With Quote
  #11  
Old August 18th, 2004, 04:56 PM
smr23 smr23 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 smr23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

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:
Originally Posted by mai
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.


Reply With Quote
  #12  
Old October 12th, 2005, 01:42 AM
manishkaushik manishkaushik is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 1 manishkaushik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 5 sec
Reputation Power: 0
Thanks

Ya it worked out.
Thanks a lot.

Manish

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Converting Fields into Rows in a table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway