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

Find first 3 letters with Form search?

New Here ,
Sep 03, 2008 Sep 03, 2008

Copy link to clipboard

Copied

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

Views

622

Translate

Translate

Report

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

Copy link to clipboard

Copied

if your db support it,

where upper(substr(myword,1, 3) = <cfqueryparam value="#ucase(form.keyword)#">

Votes

Translate

Translate

Report

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
New Here ,
Sep 03, 2008 Sep 03, 2008

Copy link to clipboard

Copied

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) = ?'.

Votes

Translate

Translate

Report

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
New Here ,
Sep 03, 2008 Sep 03, 2008

Copy link to clipboard

Copied

Sorry- I did add the extra ")" and now get:

Error Executing Database Query.
Undefined function 'upper' in expression.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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".

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Documentation