Results 1 to 5 of 5

Thread: SQL wont work

  1. #1
    Join Date
    Dec 2005
    Posts
    8

    Unanswered: SQL wont work

    Can anyone suggest why this SQL wont work?

    Someone has suggested that I have a few " in the wrong place.
    I am missing the basic understanding about variable / string concatenation.

    SELECT SupplierName, Location, ShortDescription FROM Query1 WHERE 'TimberSpecies' LIKE '%" & " + Replace(rsSearchResult__MMColParam, "'", "''") + " & "%' AND 'CategoryTable' LIKE '%" & " + Replace(rsSearchResult__MMColParam2, "'", "''") + " & "%' AND 'Location' LIKE '%" & " + Replace(rsSearchResult__MMColParam3, "'", "''") + " & "%' ORDER BY SupplierName"

    Thanks

    Mally.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    this sure looks familiar, didn't you post this in other forums? i'm sure i've answered this very question before

    'TimberSpecies' is a character string

    TimberSpecies is a column name

    the trick to writing successful sql is to test the sql outside of whatever scripting language you're using (asp? vb? jsp? foo?)

    test it right in the sql window of your favourite sql front end gui utility tool
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    please also see this answer over here -- http://www.dbforums.com/t1204443.html
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Dec 2005
    Posts
    8

    Re: SQL Help

    I understand what you are saying there but when i do as mentioned.

    SELECT SupplierName, Location, ShortDescription
    FROM Query1
    WHERE TimberSpecies LIKE '%MMColParam%' AND CategoryTable LIKE '%MMColParam2%' AND Location LIKE '%MMColParam3%'

    I get the following error when testing the SQL

    [Microsoft][OBDC Microsoft Access Driver] Too few paramaters. Expected 1.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    your answer is over here -- http://www.dbforums.com/t1204443.html

    may i please ask you not to keep all seven of your threads going? please, just settle on one
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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