Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 19th, 2002, 05:32 AM
voice220's Avatar
voice220 voice220 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Norwich, UK
Posts: 84 voice220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 sec
Reputation Power: 6
Question Looking for advice on query

Hi everyone,

I need to build two drop down menus, with dynamic items, each related to the other via their age. I'm wondering what the best way of doing this is.

I have two tables, the Name and Category column of the respective tables becoming the dropdown items:

Table: MACHINE SERIES (columns: MS_ID, NAME, FROM YEAR, TO YEAR)
Table: AGE (columns: AGE_ID, CATEGORY, FROM YEAR, TO YEAR)

Basically, the age table's job is to define age categories (for other parts of this application). In this specific task, I need to have to ages of both tables relate to each other.

For example:

Machine Series Dropdown
Machine1, 1972 - 1977
Machine2, 1996 - 2000
...

Age Dropdown
Cat1, 1970 - 1980
Cat2, 1981 - 1990
...

The functionailty I need is that when someone chooses a machine from dropdown 1 and hits submit, the contents of dropdown 2 should be limited to the approriate category and vice versa.

For example, if I select Machine1 and submit, the age dropdown should only list Cat1. Similarly if I choose Cat1 and submit, the machine series dropdown should only list machines that fall between those years.

The age categories themselves will change as time moves on, hence I am forced to do an from/to year check.

Any advice on how to best achieve this would be great! (I am coding in ASP/VBScript btw.)
__________________
Yours,
Frank Reding, IconoclastDesign.co.uk.

Last edited by voice220 : December 19th, 2002 at 08:56 AM.

Reply With Quote
  #2  
Old December 19th, 2002, 08:43 AM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 21 h 22 m 10 sec
Reputation Power: 19
I hope this doesn't come off as rude but what makes this complicated? seems pretty straight forward.

Reply With Quote
  #3  
Old December 19th, 2002, 08:57 AM
voice220's Avatar
voice220 voice220 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Norwich, UK
Posts: 84 voice220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 sec
Reputation Power: 6
You're right, it probably doesn't qualify as complicated *goes and changes the subject* but I'm still quite new to SQL and my head hurts form post-Christmas party disorder.

Reply With Quote
  #4  
Old December 19th, 2002, 09:28 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,686 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 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
SELECT AGE.AGE_ID, AGE.CATEGORY FROM AGE, MACHINE SERIES WHERE AGE.FROM YEAR = MACHINE SERIES.FROM YEAR AND AGE.TO YEAR = MACHINE SERIES.TO YEAR (use = or the appropriate < >)

Reply With Quote
  #5  
Old December 20th, 2002, 04:40 AM
voice220's Avatar
voice220 voice220 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Norwich, UK
Posts: 84 voice220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 50 sec
Reputation Power: 6
Thanks.

It all started to make a lot more sense today than it did yesterday. Apologies, I really wasn't quite with it. There must have been something in the food.

Btw, when I tried something along the lines of the above query, I got far too many results, the age categories repeating for every machine series entry. Even adding DISTINCT did not solve it because I drew from two tables.

I solved by splitting it into two queries, one to find out the relevant to and from data for a given age category, and the second to limit the machine series to those dates. I knwo it's an extra query but it works nicely
.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Looking for advice on complicated query


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