Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

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 September 9th, 2005, 02:39 PM
frysanek frysanek is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 frysanek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 49 sec
Reputation Power: 0
Transposing a table (sub items)

This may be a naive question, and I have found a way to work around the problem, but I'd like to do this right, and I"m curious. Note also that I'm a beginner. There is a bit of background to this question, and I can answer that if there is interest, but it boils down to this. I have a table like the following: (equipment inventory items) (sorry can't seem to insert a Tab)

ID:Tag:Ref
a : j1
b : j2
c : k1 : a
d : k2 : a

Where items "c" and "d" are sub items of "a". Because I don't have access to make tables, and running multiple queries is really slow in this case (I'm using MS Access through ODBC), I'm trying to list all the inventory items with Tag "j*" but include their sub items. So I want something like this:

ID : Tag : Ref : Sub1 : Sub2 : Sub3
a : j1 : c : d
b : j2

I'm willing to say that there won't be more than n sub items (say n=4)

I think some of my speed problems come from the fact that the Ref column is not indexed, making the following query kind of slow (1-2 seconds) Not to mention the fact that I'm doing it in MS Access over ODBC connections.

SELECT tbl.id, tbl.tag, tbl.ref, tbl2.tag AS Sub1
FROM tbl INNER JOIN tbl AS tbl2 ON tbl.id=tbl2.ref


Is there a convenient way to do this without having to make tables in the database? Maybe I'm thinking about it all wrong, and there is an easy way, but I haven't been able to find it.

Any help will be appreciated. Thanks

Reply With Quote
  #2  
Old September 10th, 2005, 03:34 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,826 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 11 h 35 m 33 sec
Reputation Power: 278
Solution from Quest (might be a bit overkill)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Transposing a table (sub items)


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 6 hosted by Hostway