Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Find first 3 letters with Form search?

Guest
Sep 03, 2008 Sep 03, 2008
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.
TOPICS
Advanced techniques
691
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 03, 2008 Sep 03, 2008
if your db support it,

where upper(substr(myword,1, 3) = <cfqueryparam value="#ucase(form.keyword)#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2008 Sep 03, 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) = ?'.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2008 Sep 03, 2008
Sorry- I did add the extra ")" and now get:

Error Executing Database Query.
Undefined function 'upper' in expression.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 03, 2008 Sep 03, 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".
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 03, 2008 Sep 03, 2008
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources