Overmyhead2
Programmer
I need help. I've been reading everywhere. I've learned so far that this is not good programming practice to use col names like this.(forgive me). BUT.. just this once I need a SELECT query that will use Column Names to help put item descriptions into a report. I think I need dynamic SQL.
2 tables:
1. tblOrders has OrderID, OrderDate, SiteID, Category, Item1,Item2,Item3,Item4, so on to Item48
2. tblItems has ItemID(autonum),ItemName (Item1,Item2,Item3,..), Category, Description, Units..
When an Order is reviewed I SELECT Category, All Items
from tblOrders WHERE SessionID = SiteID AND #PickDate# = OrderDate. When displayed I want to show:
ITEM QTY
--------------------------------------------
(tblItems.Description&Units) (tblOrders.Item1)
(tblItems.Description&Units) (tblOrders.Item2)
(tblItems.Description&Units) (tblOrders.Item3)
ect... if Qty is not 0.
I have this so far
I hope I didn't go overboard in explaining.
Apreciate any ideas.
Victoria
2 tables:
1. tblOrders has OrderID, OrderDate, SiteID, Category, Item1,Item2,Item3,Item4, so on to Item48
2. tblItems has ItemID(autonum),ItemName (Item1,Item2,Item3,..), Category, Description, Units..
When an Order is reviewed I SELECT Category, All Items
from tblOrders WHERE SessionID = SiteID AND #PickDate# = OrderDate. When displayed I want to show:
ITEM QTY
--------------------------------------------
(tblItems.Description&Units) (tblOrders.Item1)
(tblItems.Description&Units) (tblOrders.Item2)
(tblItems.Description&Units) (tblOrders.Item3)
ect... if Qty is not 0.
I have this so far
Code:
<CFQUERY NAME="GetDetail" DATASOURCE="#DataSource#">
DECLARE @Item1 int
SELECT *
FROM BREAD m, bread oi
WHERE oi.OrderID = #URL.OrderID#
AND oi.OrderID IN
(SELECT o.OrderID FROM Bread o
WHERE o.SiteID = #SESSION.Auth.SiteID#)
Apreciate any ideas.
Victoria