MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 9th, 2012, 05:36 PM
stoyleg stoyleg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 7 stoyleg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 47 m 14 sec
Reputation Power: 0
Rearrange columns with query

Does anyone know how I'd perform a query in order to achieve the following, based on the attached image...

I want to stack each of the 'cm' columns by 'TransectNumber', so the resulting table/query will have TransectNumber (1,2,3 etc) as columns and the associated 0-90cm values as entries for each column.

So based on the screenshot I want to have 3 columns called (e.g.) Transect1, Transect2 and Transect3, and each column would have 100 entries.

Hope that makes sense.

Many thanks


Last edited by stoyleg : October 9th, 2012 at 06:35 PM. Reason: Bad title

Reply With Quote
  #2  
Old October 10th, 2012, 02:05 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
The correct answer is 'normalise your data and handle the display logic at the application level'.

If you want someone to suggest how you can emulate this using the present structure, I suggest you provide CREATE and INSERT statements for just 3 transects, 3 columns, and 3 results in each, together with the result set you'd expect from your query. Perhaps someone will be kind enough then to offer a non-normalised approach and maybe even demonstrate what a properly normalised table might look like.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Tearing my hair out!

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap