Help with the SQL "WHERE" clause

Results 1 to 2 of 2

Thread: Help with the SQL "WHERE" clause

  1. #1
    Join Date
    Dec 1969

    Default Help with the SQL "WHERE" clause

    I&#039m having problems trying to restrict records within a table.<BR><BR>&#060;--- CODE ---&#062;<BR>FormOS = Request.Form("OS")<BR>FormCat = Request.Form("Cat")<BR>SQLText = "select * from TechTips where OS = FormOS AND Category = FormCat"<BR>&#060;--- END CODE ---&#062;<BR><BR>As you can see I am trying to select only the records with a specific OS AND Category. But it keeps returning ALL of the records in the table. What am I doing wrong?

  2. #2
    Marcos Guest

    Default RE: Help with the SQL

    Don&#039t you really mean something like this? (assuming OS and Category on not numeric)<BR><BR>&#060;--- CODE ---&#062;<BR>FormOS = Request.Form("OS")<BR>FormCat = Request.Form("Cat")<BR>SQLText = "select * from TechTips"<BR>SQLText = SQLText & " where OS = &#039" & FormOS & "&#039"<BR>SQLText = SQLText & " AND Category = "&#039 & FormCat & "&#039"<BR>&#060;--- END CODE ---&#062;<BR><BR>Also, please do this:<BR><BR>Response.Write (SQLText)<BR><BR>If you are still having problems do the above and post the results of that response.write. First find out "what" you have built and then determine "how" to fix it.<BR><BR>-Marcos<BR>

Posting Permissions

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