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)
 Query multiple word search

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-07-29 : 11:55:47
How to do a multiple word search via select is it possible?

following three words anywhere in the column record_desc
"wi-fi" "launch" "iphone"

select * from table_order where record_desc like

Thank you very much for the helpful info

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-07-29 : 11:57:56
[code]select * from table_order where record_desc like '%wi-fi%' or record_desc like '%iphone%' or record_desc like '%launch%'[/code]
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-07-29 : 12:44:58
Thank Vijay, but if i want to write something dynamic in storeprocedure.
It could be 5 or 6 or 7 words any number.
How can i write a dynamic functionality within SP to handle that many like conditions is it possible?

Thank you very much for the helpful info.

quote:
Originally posted by vijayisonly

select * from table_order where record_desc like '%wi-fi%' or record_desc like '%iphone%' or record_desc like '%launch%'


Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-07-29 : 12:45:25
quote:
Originally posted by cplusplus

Thanks Vijay, but if i want to write something dynamic in storeprocedure.
It could be 5 or 6 or 7 words any number.
How can i write a dynamic functionality within SP to handle that many like conditions is it possible?

Thank you very much for the helpful info.

quote:
Originally posted by vijayisonly

select * from table_order where record_desc like '%wi-fi%' or record_desc like '%iphone%' or record_desc like '%launch%'




Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-07-29 : 13:19:39
You can Pass these values to the SP, and have a split function insert them as different rows into a temp table. You could then join that temp table to table_order like...
SELECT a.* FROM table_order a
INNER JOIN #temp b on a.record_desc like '%' + b.tempcolumn + '%'

You can search for split functions in sqlteam. There are lots.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-07-29 : 15:59:20
Perfect vijay, thank you very much for the helpful logic hint.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-07-30 : 09:03:51
welcome.
Go to Top of Page

jamesthank
Starting Member

3 Posts

Posted - 2010-08-04 : 00:56:52
quote:
Originally posted by cplusplus

How to do a multiple word search via select is it possible?

following three words anywhere in the column record_desc
"wi-fi" "launch" "iphone"

select * from table_order where record_desc like

Thank you very much for the helpful info

Go to Top of Page

jamesthank
Starting Member

3 Posts

Posted - 2010-08-04 : 00:58:24
Thank you so much. May GOD bless you.

Cheers...

James.
Go to Top of Page
   

- Advertisement -