SELECT * from prds WHERE 1=1 AND (prds.title like '%test%' OR prds.title like '%test1%')
How to implement that logic for more than 3 keywords(on the fly)? Thanks Raj > Raj, > > That is the same as writing this: > > SELECT * from prds > WHERE 1=1 > and prds.title like 'test,test1' > > Unless prds.title is exactly 'test,test1' you will not get any records > returned. > > Like requires the use of wildcards to be valuable. You'd want your > query to look like: > > SELECT * from prds > WHERE 1=1 > AND (prds.title like '%test%' > OR prds.title like '%test1%') > > So you'd need to loop through your list of keywords, and construct > your query appropriately. Also note the use of parenthesis. This is > important when you are using ANDs and ORs together. > > Cheers, > Kris > > > > what's wrong with this code.... > > > > <cfset keyword = "test,test1"> > > > > <cfquery name='getdata' datasource='abcde'> > > SELECT * from prds > > WHERE 1 = 1 > > and prds.title like <cfqueryparam cfsqltype="cf_sql_varchar" > list="true" value="#keyword#"> > > </cfquery> > > > > I am trying to get data from database with those two key words, if > any title has the keyword test or test1 pull that data, i don't know > what i am missing... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:285070 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

