SQL Statement and Access Database Question

Results 1 to 2 of 2

Thread: SQL Statement and Access Database Question

  1. #1
    Join Date
    Dec 1969

    Default SQL Statement and Access Database Question

    I have a SQL Statement:<BR><BR>sqltext="SELECT * FROM SSTP1 "<BR>sqltext=sqltext & " WHERE State IN(&#039" & varState & "&#039) ORDER BY Institution;"<BR><BR>I want to add another condition "WHERE Teacher or Student IN (&#039" & varStudent & "&#039)<BR><BR>Two Questions 1. how would I add this condition? (With &&#039s? With the word and?)<BR>2. The field name in the database is "Teacher or Student". (The field will either have Teacher or Student in it.) Do I need to rename the field to a single word? <BR><BR>When I tried using this field with it&#039s multiword name, it did not work.<BR><BR>Thanks, <BR>Chris

  2. #2
    Patty Guest

    Default RE: SQL Statement and Access Database Question

    First, it is best that you keep all your field names "attached" together. This will immensely reduce your troubles.<BR><BR>Second, you can have multiple WHERE conditions in your statement as follow:<BR><BR>sqltext="SELECT * FROM SSTP1 "<BR>sqltext=sqltext & "WHERE State=&#039" & varState & "&#039 AND "<BR>sqltext=sqltext & "Teacher_or_Student=&#039" & varStudent & "&#039 "<BR>sqltext=sqltext & "ORDER BY Institution"<BR><BR>then execute your sqltext through conn.execute<BR><BR>Hope this helps.<BR>Regards,<BR>Patty<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