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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax help with sql statment 1

Status
Not open for further replies.

Kris912

Programmer
Joined
Jul 29, 2005
Messages
27
Location
US
I've always been confused when writing sql withing the ASP syntax parameters. Can someone help me with this statement?

choice = request("choice")

P_Status = request("P_Status)

sql = "select * from Projects "
sql = sql & "where ( title like & choice ) & "
sql = sql & "and (P_Status = "complete") "
sql = sql & "order by Title ASC"
set rs = connection.execute(sql)

P_Status is one of the fields in my database as well as title. Choice is the variable in my Select case statement. My user chooses a letter via a radio button then the select statement processes it and my sql statement is supposed to get all the Titles that begin with that letter from the db. I'd appreciate any help I can get. Thanks!
 
something like this:

Code:
sql = "select * from Projects"
sql = sql & " where Title like '"&choice&"%'"    
sql = sql & " and P_Status = "complete" "
sql = sql & " order by Title ASC"
set rs = connection.execute(sql)

-DNG
 
oops...this one:

Code:
sql = "select * from Projects"
sql = sql & " where Title like '"&choice&"%'"    
sql = sql & " and P_Status = [red]'complete'[/red]"
sql = sql & " order by Title ASC"
set rs = connection.execute(sql)

also if you using access db then replace % with a *

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top