Skip to main content
September 3, 2008
Question

Find first 3 letters with Form search?

  • September 3, 2008
  • 2 replies
  • 759 views
Greetings

I have a search form in which the user types the first 3 letters of a word - the results should display only those words that begin with the letters.

What would the correct SQL format be to accomplish this?

WHERE myword LIKE '%#Trim(FORM.Keyword)#%' ?

Thanks in advance.
This topic has been closed for replies.

2 replies

Inspiring
September 3, 2008
Functions vary with the db.

Since you are using access, open it up and see where the f1 key leads you. Or, google "ms access string functions".
Inspiring
September 3, 2008
just do...

WHERE myword LIKE <cfqueryparam value="#form.keyword#*">

There shouldn't be a need to do any string functions because MS Access queries are not case-sensitive.
Inspiring
September 3, 2008
if your db support it,

where upper(substr(myword,1, 3) = <cfqueryparam value="#ucase(form.keyword)#">
September 3, 2008
Thanks again for your quick response, Dan.

Here is the error message I am getting (MS Access DB):

Error Executing Database Query.
Missing ), ], or Item in query expression 'upper(substr(vendor_company,1, 3) = ?'.