Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 search for "value1" and "value2"

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-01-18 : 07:17:03
Hi

If I have one search box in a webform and enter ford + volvo, can I then do a search in sql server for both ford and volvo in a database table. Is there some built in support for that kind of search?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-18 : 07:40:15

where '+'+@search_value+'+' like '%+'+col+'+%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-01-18 : 08:28:17
Hi

Hmm, this combination should have retrieved rows...

SELECT     Symptome, Faq_ID
FROM dbo.tbl_Faq
WHERE ('+' + 'After + above' + '+' LIKE '%+' + Symptome + '+%')


On this symptome text...

After a time of use on above car


Or am I doing something wrong?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-18 : 08:37:39
Did symptome column has values like after,above,etc?

declare @t table(symptome varchar(100))
declare @search varchar(100)
set @search='after+above'

insert @t select 'above' union all select 'after' union all select 'all'

select * from @t
where ('+' + ''''+replace(@search,'+','''+''')+'''' + '+' LIKE '%+''' + Symptome + '''+%')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-01-18 : 09:43:14
Yes the symptom column ghad this value...

"After a time of use on above car"
Go to Top of Page
   

- Advertisement -