Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement

Status
Not open for further replies.

biggvito

Technical User
Oct 22, 2001
14
GB
I have a html front end page where the user selects 3 items from a group of combo lists.

The important one is named "sTime" and can be values such as 0900,0930,1000 etc

After selection and then submission an asp page loads where i want to query a table depending on the selections made on the html front end. the sTime coresponds to a column name in my table.

so for the sTime selection made i would want the query ideally to be

SELECT sTime from table_name WHERE etc etc so

but actually getting the sTime value (which say is 0900) into the query is mind boggling because to access the sTime value previously ive had to use:

'" & request("sTime") & "'

which equates to

SELECT '" & request("sTime") & "' from table_name WHERE etc etc so
but this dont work.

i know this may be a bit confussing but can anyone help me please!
 
I think you are getting sTime mixed up with the name of the column on your table.

It should be something like this:

Select "column_name" from table where "column_name" = request("sTime").

You could also be having problems with inconsistent datatypes. Make sure that sTime is the same datatype as the values you are comparing it against in your table.

Hope this helps.
 
thanks for the quick responce but sorry i'm still confused:

Heres my table columns in table name "main":

Name,Age,0900,1000,1100,1200,1300,1400,1500,1600,1700

then there is a combo box with the options of
1.0900
2.1000
3.1100
4.1200
5.1300
etc

if the user selects say 2.1000 then sTime will equal 1000

then in the asp page using a select statement i want it to show all in the 1000 column

yes "SELECT 1000 FROM main" will show that column if i am correct but i want not to have the put in 1000 or 1200 etc each time i want it to use sTime for the column name as i have loads of columns

"SELECT sTime FROM main" so whateever the selection of sTime is will be the value used.










 
try

"SELECT "&sTime&" FROM main..."

 
If I am understanding you correctly you want to do the following:

Based on the column picked by the user, you want to select the information in that column which is found in the "main" table. In order to do this you want to be able to build your sql statement dynamically from the user's selection without worrying about what that selection actually was. Is that correct? If I am correct, then you want to do the following:

Select " & request("sTime") & " from main
 
What's the name of the time column in the database? Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top