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.
| Author |
Topic |
|
ssr972
Starting Member
2 Posts |
Posted - 2004-12-07 : 03:33:30
|
| Hi,I need some help on a Query.I need to make a kind of search engine.Right now, I use a query that works for some searches.Here's the contains of one of my tables.IDK Actors1 Brad Pitt2 Kevin Costner3 Robert de Niro4 Tom Hanks5 Al PacinoIf the user writes : - Brad the seach returns Brad Pitt - Bra the search returns Brad Pitt - no the search returns Robert de Niro, Al Pacino - Brad no the search returns Bradd Pitt, Robert de Niro, Al PacinoSo I would like to rewrite the query to perform this :If the user writes - no I don't want to retreive Robert de Niro neither Al Pacino - Pacino I want to retreive Al Pacino - Bra Pacino, I want to retreive Al Pacino - Brad Pacino, I want to retreive Brad Pitt, Al Pacino and if it's possible : If the user write Pacinos, I would like to retrieve Al PacinoIf someone could help me on this topic.RegardsStan |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-07 : 03:46:32
|
| try patindex in your where clause or use full-text--------------------keeping it simple... |
 |
|
|
ssr972
Starting Member
2 Posts |
Posted - 2004-12-07 : 05:49:11
|
| Thanks Jen..Just a question... I ve tried to setup the full text and it seems to work fine.So, my question is.. How to automatically update the catalogue, when I update the tables ?I ve seen there's a scheduler but does it mean, when I add some records into the tables, the catalogue is not updated until the procedure starts ? |
 |
|
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2004-12-07 : 10:31:48
|
quote: Originally posted by ssr972 Thanks Jen..Just a question... I ve tried to setup the full text and it seems to work fine.So, my question is.. How to automatically update the catalogue, when I update the tables ?I ve seen there's a scheduler but does it mean, when I add some records into the tables, the catalogue is not updated until the procedure starts ?
Use a trigger?------------->>> BREAKING NEWS!!! <<<------------- Saddam Hussien has weapons of mass destrcution |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-07 : 22:02:45
|
quote: Originally posted by ssr972 Thanks Jen..Just a question... I ve tried to setup the full text and it seems to work fine.So, my question is.. How to automatically update the catalogue, when I update the tables ?I ve seen there's a scheduler but does it mean, when I add some records into the tables, the catalogue is not updated until the procedure starts ?
if you already have it scheduled and with a job, you can start the job when changes are made via trigger, sp_start_job.--------------------keeping it simple... |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-12-07 : 22:38:10
|
Here is an SQL Technique based on the following article: http://www.sqlteam.com/item.asp?ItemID=2652 create table t (IDK int, Actors varchar(20))insert into tselect 1,'Brad Pitt' union allselect 2, 'Kevin Costner' union allselect 3, 'Robert de Niro' union allselect 4, 'Tom Hanks' union allselect 5, 'Al Pacino'declare @searchstring varchar(20)set @searchstring = 'Brad Pacino'select t.*from( SELECT NullIf(SubString(' ' + @searchstring + ' ' , n , CharIndex(' ' , ' ' + @searchstring + ' ' , n) - n) , ' ') AS Word FROM numbers WHERE n <= Len(' ' + @searchstring + ' ') AND SubString(' ' + @searchstring + ' ' , n - 1, 1) = ' ' AND CharIndex(' ' , ' ' + @searchstring + ' ' , n) - n > 0) d1join( SELECT IDK, NullIf(SubString(' ' + Actors + ' ' , n , CharIndex(' ' , ' ' + Actors + ' ' , n) - n) , ' ') AS Word FROM numbers, t WHERE n <= Len(' ' + Actors + ' ') AND SubString(' ' + Actors + ' ' , n - 1, 1) = ' ' AND CharIndex(' ' , ' ' + Actors + ' ' , n) - n > 0) d2 on d2.word = d1.wordjoin t on t.IDK = d2.IDKdrop table t |
 |
|
|
|
|
|
|
|