Hello,
I have a question regarding the creation of an SQL query,
but I'll need to give some background first.
I build and sell products that are made up of a variety of
parts.
Usually, an order will come in consisting of 2 or 3
products, (which in turn consists of multiple parts), and
any particular part may be part of more than one final product, i.e a many-to-many relationship.
As each item is stored in a different location, it is an
inefficient use of my time to get all the parts for the 1st
product, then all the parts for the 2nd product etc,
especially when they have parts in common.
I'm trying to create a web based (ASP) application that
will allow me to enter the quantity of each product required, but then produce a list by Part Number, so I
retrieve all common parts together.
I have an Access database with the following tables and
example data:
tbl_Parts
=========
PartNumber (Primary Key) | PartName | StorageLocation |etc.
-------------------------|----------|-----------------|----
5631 | Test 1 | Test A |
5675 | Test 2 | Test B |
5805 | Test 3 | Test C |
tbl_UpgradeKits
===============
UpgradeKitNo (PK) | Name | etc.
------------------|------|-----
UG1 | T1 |
UG2 | T2 |
tbl_UG_Parts (resolving the many-to-many)
============
UpgradeKitNo (PK) | PartNumber (joint PK) |
------------------|-----------------------|
UG1 | 5631 |
UG1 | 5675 |
UG1 | 5805 |
UG2 | 5675 |
UG2 | 5805 |
This database was created by myself purely for the use of
the ASP website, we already have another system in place
that takes care of the ordering and invoicing. Therefore I
don't need to /store/ quantity ordered etc.
So finally I get to my question (sorry about the wait!):
If I have an ASP page that reads in the quantity of the
Upgrade Kits required e.g 1 x UG1 and 2 x UG2, what SQL
queries should I use to find out what parts a product
consists of, AND THEN produce a list saying I need (in this
example):
1 x 5631
3 x 5675
3 x 5805
Thanks in advance for your help, and sorry about the long
post, but I wanted to provide as much information as possible.
I have a question regarding the creation of an SQL query,
but I'll need to give some background first.
I build and sell products that are made up of a variety of
parts.
Usually, an order will come in consisting of 2 or 3
products, (which in turn consists of multiple parts), and
any particular part may be part of more than one final product, i.e a many-to-many relationship.
As each item is stored in a different location, it is an
inefficient use of my time to get all the parts for the 1st
product, then all the parts for the 2nd product etc,
especially when they have parts in common.
I'm trying to create a web based (ASP) application that
will allow me to enter the quantity of each product required, but then produce a list by Part Number, so I
retrieve all common parts together.
I have an Access database with the following tables and
example data:
tbl_Parts
=========
PartNumber (Primary Key) | PartName | StorageLocation |etc.
-------------------------|----------|-----------------|----
5631 | Test 1 | Test A |
5675 | Test 2 | Test B |
5805 | Test 3 | Test C |
tbl_UpgradeKits
===============
UpgradeKitNo (PK) | Name | etc.
------------------|------|-----
UG1 | T1 |
UG2 | T2 |
tbl_UG_Parts (resolving the many-to-many)
============
UpgradeKitNo (PK) | PartNumber (joint PK) |
------------------|-----------------------|
UG1 | 5631 |
UG1 | 5675 |
UG1 | 5805 |
UG2 | 5675 |
UG2 | 5805 |
This database was created by myself purely for the use of
the ASP website, we already have another system in place
that takes care of the ordering and invoicing. Therefore I
don't need to /store/ quantity ordered etc.
So finally I get to my question (sorry about the wait!):
If I have an ASP page that reads in the quantity of the
Upgrade Kits required e.g 1 x UG1 and 2 x UG2, what SQL
queries should I use to find out what parts a product
consists of, AND THEN produce a list saying I need (in this
example):
1 x 5631
3 x 5675
3 x 5805
Thanks in advance for your help, and sorry about the long
post, but I wanted to provide as much information as possible.