pf » Searching without Verity
Searching without Verity
Sometimes you need to search a database query without using verity. In general Verity should be used when possible, because it will yeild much better results, at better performance than the solution I'm about to show. But there are reasons for not using verity, for instance compatibility with BlueDragon, a highly customized search query, or a shared host that doesn't allow it.
Single keyword searches are easy using the LIKE operator in SQL WHERE column LIKE '%something%'. If you need to search using multiple keywords, its a harder. Here's an exmple
SELECT stuff FROM table WHERE column LIKE '%#Replace(Trim(q), " ", "%' OR column LIKE '%", "ALL")#%'
Here column would be the database field your searching and q would be your search string. Basically that code replaces all spaces with:
%' OR column like '%
So if your search string is "Monday Tuesday" the resulting query would be:
WHERE column LIKE '%Monday%' OR column LIKE '%Tuesday%'
You can ofcourse easily replace the OR with an AND, or use a variable.
SELECT text FROM table WHERE text REGEXP '[[:<:]]word[[:>:]]';
- Mastering CFQUERYPARAM
- Google Code Search for ColdFusion
- Speaking at CFUNITED 2008
- Getting ColdFusion SQL Statements from SQL Server Trace
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
RSS
add to del.icio.us
Pete Freitag is a software engineer, and web developer located in











