SQL statement is wrong

Results 1 to 3 of 3

Thread: SQL statement is wrong

  1. #1
    Join Date
    Dec 1969

    Default SQL statement is wrong

    I am trying to code a search page as follows:<BR><BR>In a drop down menu, I have looped through several recorsets. The user chooses the title they are interested in and hits a search button.<BR><BR>The drop down form contents are posted to a seperate page which puts the drop down selection into a variable called search.<BR><BR>My SQL statement is then:<BR><BR>SQL = "SELECT * FROM tbl_Schools where txt_title_1 OR txt_title_2 OR txt_title_3 OR txt_title_4 OR txt_title_5 OR txt_title_6 OR txt_title_7 OR txt_title_8 OR txt_title_9 OR txt_title_10 OR txt_title_11 OR txt_title_12 OR txt_title_13 ="&search<BR><BR>but I keep getting a syntax error.<BR>Can anyone help me at all?<BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default Yuck, but ok...

    SQL = "SELECT * FROM tbl_Schools where txt_title_1="&search&" OR txt_title_2="&search&" OR txt_title_3="&search&" OR txt_title_4="&search&" OR txt_title_5="&search&" OR txt_title_6="&search&" OR txt_title_7="&search&" OR txt_title_8="&search&" OR txt_title_9="&search&" OR txt_title_10="&search&" OR txt_title_11="&search&" OR txt_title_12="&search&" OR txt_title_13 ="&search<BR><BR>However, this looks suspiciously like bad database design. The fact you have all those OR fields looks like those title fields should be in a separate table with a one-to-many relationship between the two...<BR><BR>Craig.

  3. #3
    Join Date
    Dec 1969

    Default RE: SQL statement is wrong

    i dont think any DB allows query like this!!!<BR>use<BR>txt_title_1=&#039;"&search&"&#03 9; or txt_title_2=&#039;"&search&"&#039; and so on

Posting Permissions

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