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

Expanding Search Functionality ??

Explorer ,
Jul 19, 2006 Jul 19, 2006

Copy link to clipboard

Copied

Hello,

I have a table that has a column for a title and a column for description. I want to create a search functionality that will allow a user to enter in a string and click submit to search through both the title and description columns.

I have a generic sql query:

...where title LIKE '%#txtSearch#%' or description LIKE '%#txtSearch#%'

to get results right now. I'd like to extend my searching to allow a user to enter multiple words that don't have to be in perfect sequence to get a result. Does any one have any ideas on how to do this?

Thanks!
James
TOPICS
Advanced techniques

Views

306

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 ,
Jul 19, 2006 Jul 19, 2006

Copy link to clipboard

Copied

you would have to put all the words in a list first, with no spaces between the list elements. Then, in your query, you need something like:

and
(
<cfloop list=yourlist index="word">
title like '%#word#%' or description '%#word#%'
<cfif listfind(yourlist, word) lt listlen(yourlist)>
or
</cfloop>
)

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
Contributor ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

LATEST
How many records are we talking about? SQL Server has Full Text Indexing that does exactly what you are looking for and is the best way to go if you will have large amounts of data.

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