can anybody help me with the question below: my table consists of the fields like IdTour TourName TourType (transfer, tour) Tourtime i want to come out with formula that could return rates next to the tour name based on the time and tourtype in the following rate list transfer 18:00 - 6:00 $20 transfer 6:00 - 18:00 $10 tour 23:59 - 10:00 $30 tour 10:01 - 23:59 $10 I have tried this with "if...elseif..else..end if" but it doesn't work the half working script i'm using is as follows: <% set c=server.createobject("adodb.connection") c.open("jusa") q="select * from db" dim r response.write(q) set r=c.execute(q) do while r.eof <tr> <td> <%=r(TourName)%> </td> <td> if r("tourtype")="transfer" and r("Tourtime")<#23:59# and r("Tourtime")>#10:00# then response.write("10") elseif r("tourtype")="transfer" and r("Tourtime")<#10:00# and r("Tourtime")>#23:59# then response.write("20") ElseIf r("tourtype")="tour" and r("Tourtime")<#18:00# and r("Tourtime")>#6:00# then response.write("15") ElseIf r("tourtype")="tour" and r("Tourtime")>#18:00# and r("Tourtime")<#6:00# then response.write("30") end if </td> </tr> <% r.movenext loop c.close %> Code (markup):
The best solution for this would be to create the tables like this TourTypeTable ----TourTypeID ----TourTypeName TourTimeSlotTable ---TimeSlotID ---TourType ---TimeSlotDescription TourTable ---TourID --- TourName --- TourTypeID ;Foreign key ---TourTimeSlotID 'Foreign key Just do a join of all the 3 tables and you will get the correct values. No cryptic SQL necessary. You will need to do an outer join selecting all records from ToursTable