SELECT statement Question...

Results 1 to 3 of 3

Thread: SELECT statement Question...

  1. #1
    brclev Guest

    Default SELECT statement Question...

    Is it possible to change the FROM element in a SELECT statement "on the fly"? What I mean is I need the FROM element of the SELECT statement to update depending on what choice is made from a drop-down menu. Is this possible? If so, I would really appreciate some help.<BR>-Thanks

  2. #2 Guest

    Default RE: SELECT statement Question...

    Your question is very vague, and the fact that you would need to ask is makes me wonder why you developing internet applications.<BR><BR>But to answer you question:<BR>If you are talking about generating SQL statements in your ASP code then the answer is YES. You can change any part of the SQL statement in response to client requests. <BR><BR>An SQL select statement takes the form:<BR><BR>"Select Fieldlist from TableName where condition order by fieldlist"<BR><BR>Fieldlist may contain one or more fields or "*" to indicate ALL<BR>Condition is a clause where criteria are specified for one or more fields<BR>Order by Fieldlist specifies a list of fields to sort by and ascending or descending<BR>Any fields and tables in the SQL statement must exist in the database.<BR><BR>However, normally in ASP database programming you would not change the FROM part , because that specifies the table. You would normally change the where condition and the sorting. If you are wanting to change the table, this suggests bad database design.<BR><BR>To comment further I would need to have some idea what you want to do.

  3. #3
    Join Date
    Dec 1969

    Default this is easy, you made it hard=)

    let&#039s say you did it through that drop down, let&#039s see how easy this is:<BR><BR>&#060;%<BR>fromstatement=request.form(" dropdownmenu")<BR>set dbcn=server.createobject("adodb.connection")<BR>db "dsn=mydsn"<BR>set dbrs=server.createobject("adodb.recordset")<BR>dbr s.activeconnection=dbcn<BR> "select * from " & fromstatement<BR>dbrs.close<BR>dbcn.close<BR>set dbrs=nothing<BR>set dbcn=nothing<BR>%&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts