This is a discussion on "Very Ugly SQL statement. Help Needed." within the Classic ASP section. This forum, and the thread "Very Ugly SQL statement. Help Needed. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Very Ugly SQL statement. Help Needed.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Very Ugly SQL statement. Help Needed.
I'll try to make this as brief as possible. I am having trouble getting this SQL statement to work. Any suggestions would be appriciated. I am using Classic ASP with an Access Backend.
The object: The user will submit a productid and stateid through a form to find a list of stores in the given state that sells the given product. The DB schema: wtbProducts (table) productID Alias wtbProductWarehouses (table) productID warehouseID wtbWarehouseStores (table) warehouseID storeID wtbStoreStates (table) storeID stateID wtbStores (table) storeID Alias (name of store) WebAddress Other tables which I don't think are needed in the SQL wtbWarehouses (table) warehouseID Alias CustomerNumber wtbStates (table) stateID Code Alias Show The data I want returned: Alias and WebAddress from wtbStores The code that I have written:
The Error that I am getting: Microsoft JET Database Engine error '80040e14' Syntax error. in query expression 'storeID IN ( SELECT * FROM wtbStoreStates WHERE stateID = ) AND storeID IN ( SELECT * FROM wtbWarehouseStores WHERE warehouseID IN ( SELECT * FROM wtbProductWarehouses WHERE productID = ))'. /getStores.asp, line 21 Any suggestions? Thanks, Jason |
|
|
|
#2
|
|||
|
|||
|
Re: Very Ugly SQL statement. Help Needed.
Sorry. I forgot to explain the product/warehouse/store relationship...
Warehouses order different products. This relationship is set in wtbProductWarehouses. Stores then can order any of the products that a Warehouse carries. If a Warehouse does not carry a product the store can not order it. The relationship of stores to Warehouses is set in wtbWarehouseStores. Thus in my thinking we have to use the productid submitted from the form to find warehouses which carry that product. Then we find which stores subscribe to those warehouses and then finally figure out which stores are in the stateid provided from the form. I hope this explains the mess. Thanks |
|
#3
|
|||
|
|||
|
Re: Very Ugly SQL statement. Help Needed.
Whilst one could hopefully make an educated guess, I think it would be useful if you edited your original post and indicated primary, secondary and foreign keys.
|
![]() |
| Tags |
| asp, sql |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ugly Dog Designs | macman0295 | Free Web Site Critique | 3 | Feb 5th, 2008 10:35 |
| PHP If Statement... | mcdanielnc89 | PHP Forum | 16 | Dec 9th, 2007 17:44 |
| If..Else statement help | IanW | PHP Forum | 3 | Oct 6th, 2006 13:40 |
| Help with If Statement. | JohnMitch | Classic ASP | 2 | Jan 5th, 2005 01:05 |
| With Statement | Trebz | Classic ASP | 2 | Feb 2nd, 2004 14:56 |