If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL wont work

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-05, 08:34
malhyp malhyp is offline
Registered User
 
Join Date: Dec 2005
Posts: 8
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.
Reply With Quote
  #2 (permalink)  
Old 12-12-05, 13:07
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-12-05, 13:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
please also see this answer over here -- http://www.dbforums.com/t1204443.html
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 12-13-05, 05:24
malhyp malhyp is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 12-13-05, 06:37
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On