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!

Select Statement help.... 1

Status
Not open for further replies.

sladewilson

Programmer
Feb 14, 2002
90
US
I can't seem to get this to work right... I am certain that my syntax is not correct but I don't know where to find examples.

This works like a champ (but shows all records):
objRst.Open "Select * FROM Products " & where

I want to filter out all records marked as deleted.
The field in the database is named "deleted" and the value in the field is "yes" (without the quotes of course).

This will not work:
objRst.Open "Select * FROM Products " & where & "AND deleted <> yes"

Any ideas how I can write the statement to show records that are not marked as deleted?

 
how about this:

objRst.Open "Select * FROM Products where deleted <> 'yes' "

-DNG
 
Well yeah... but "where" is actually a variable.

It is set above this... sorry... I should have show that part of the code as well.

This is what the code really looks like as is:

<%
formFields = Array("code", "name", "price", "sale-price", "ship-weight", "brand", "category1")
dbFields = Array("code", "name", "price", "sale-price", "ship-weight", "brand", "category1")

where = ""
delimiter = " WHERE "

For fnum = 0 To UBound( formFields )
fval = Request.Form( formFields(fnum) )
If ("X" & fval) <> "X" Then
where = where & delimiter & dbFields(fnum) & " LIKE '%" & fval & "%'"

End If

Next

objRst.Open "Select * FROM Products " & where
%>
 
ok then try this:

dim blah

blah = "Select * FROM Products " &where& " AND deleted <> 'yes'"

'response.write blah

objRst.Open "blah"

i would suggest you to do response.write to see if your query is constructed correctly...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top