Basic SQL help needed

Results 1 to 2 of 2

Thread: Basic SQL help needed

  1. #1
    Join Date
    Dec 1969

    Default Basic SQL help needed

    Hi Guys,<BR><BR>I need some help with displaying some records from a basic sql query.<BR><BR>The initial search page has one input form field called search_field . The user can enter one of 3 critea into the one field (firstname, surname or employeeno)<BR><BR>The results page is supposed to display the matching records. Here is where I&#039m having trouble.<BR><BR>My SQL is:<BR><BR>SQLstmt = "SELECT * FROM Confirm WHERE FirstName = Request("search_field")) OR Surname = Request("Searching")) OR EmployeeNo = Request("Searching"))"<BR><BR>I have not passed the values before hand and wondering if this is the problem, or am I completely on the wrong track. I don&#039t think the SQL "grammar" is right anyway.<BR><BR>Thanks for your time!!<BR><BR>Renee :)

  2. #2
    Richard A. Lowe Guest

    Default RE: Basic SQL help needed

    Hi Renee,<BR><BR>The idea is good, but what you need to do is build the SQL statement as a string and then pass that string:<BR><BR>SQLstmt = "SELECT * FROM Confirm WHERE FirstName = &#039" & Request("search_field") & &#039"<BR><BR>I suggest breaking the SQL statement into separate lines and building it like this:<BR>SQLstmt = ""<BR>SQLstmt = SQLstmt & "SELECT * " & vbCrLf<BR>SQLstmt = SQLstmt & "FROM Confirm " & vbCrLf<BR>SQLstmt = SQLstmt & "WHERE FirstName = &#039" & vbCrLf<BR>SQLstmt = SQLstmt & Request("search_field") & "&#039"<BR><BR>Note that you have to add the single quotes manually.<BR><BR>If this seems like a lot of work, you can always use the (very NON-commerical) code tools I&#039ve published for just this purpose at:<BR><BR><BR><BR>(BTW they are all client-side, so you I never get to see your code!)<BR><BR>HTH,<BR>Richard

Posting Permissions

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