Connecting Tech Pros Worldwide Help | Site Map

MS Access Query help - "Spidering" an item

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 9th, 2008, 05:06 PM
Newbie
 
Join Date: Apr 2008
Posts: 24
Default MS Access Query help - "Spidering" an item

For my application I need to be able to compare items in a database and output how they're all related. For example:

Ticket #1 Programs:
AA39
FR08
AA05

Ticket #2 Programs:
AA39
FR08
VS01

Ticket #3 Programs:
VS01
WB10

Ticket #4 Programs:
AA01

Now let's say someone wants to do a "spider" (that's what we call it, don't hate me) on Ticket #1. The query should select all the programs from Ticket #1 and then select any tickets that have programs matching Ticket #1. The query finds Ticket #2 has matching programs, so it should then look at all the programs in Ticket #2 and select any other tickets that have programs matching Ticket #2, and so on. So, if you do a spider on Ticket #1, you'd get back:

Ticket #1: aa39, fr08, aa05
Ticket #2: aa39, fr08, vs01
Ticket #3: vs01, wb10

So far I have something conceptual like

Select Ticket, Program as Program1 from DB where ticket = ? and Program = (Select Ticket, Program from DB where Program1 = Program..something

As you can see it kind of falls apart where my brain stops working right. I'm determined it can be done with one query.

Thanks for any help.
Reply
  #2  
Old December 9th, 2008, 11:58 PM
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Age: 60
Posts: 4,830
Default

I'm a little confused in that WB10 in Ticket #3 Programs has no match in any of the other Programs and the same with Program AA05 in Ticket #1 Programs, yet they are included in the Result Set, why?
Reply
  #3  
Old December 10th, 2008, 02:22 AM
Newbie
 
Join Date: Apr 2008
Posts: 24
Default

The reason for this is that each ticket represents a complete fix to a certain production problem. If Ticket #3 were moved without the WB10 component, things would break. The reason for this data is to get a complete picture of all the code necessary for a move once it's cleared for production.

Quote:
Originally Posted by ADezii View Post
I'm a little confused in that WB10 in Ticket #3 Programs has no match in any of the other Programs and the same with Program AA05 in Ticket #1 Programs, yet they are included in the Result Set, why?
Reply
  #4  
Old December 10th, 2008, 02:15 PM
Site Addict
 
Join Date: Jul 2008
Location: Maryland
Age: 28
Posts: 732
Default

I think you will need a table to hold your results. Here's how I would do it.

Keep a list of tickets processed and left to process, and a current ticket.
Keep a list of programs processed and left to process, organized by ticket #, and a current program.
While the lists are not empty,
Get the next program for the current ticket. If that's all for this ticket, then write a record to the table for that ticket and go to the next ticket and the first program. Otherwise add this program to the list for this ticket in the results.
Check that the program wasn't processed already by searching the pocessed programs list.
If it was, next. If it wasn't, get a list of all the tickets it's in with a SELECT or whatever, then add any of those tickets that haven't been processed to the list of tickets left to process.

Fortunately there is a searchable list item variable type you can use.
The List Class

This is just off the top of my head, so it could probably be refined some.
If you don't keep a list of tickets already processed, you run the risk of an infinite loop.
Reply
  #5  
Old December 10th, 2008, 04:02 PM
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Age: 32
Posts: 2,481
Default

Hello, somacore.

The following article could be helpful for you.
Producing a List from Multiple Records

Also this, not exactly the same but pretty close.

Regards,
Fish
Reply
  #6  
Old December 10th, 2008, 07:48 PM
Newbie
 
Join Date: Apr 2008
Posts: 24
Default

Thank you FishVal, and Chip for your very helpful suggestions. I'll look into both of these and get back if I need more advice. Thanks so much!
Reply
Reply

Bookmarks

Tags
access query

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.