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
 Development Tools
 ASP.NET
 Select From a sentance

Author  Topic 

dizzy1
Starting Member

1 Post

Posted - 2007-09-06 : 05:30:19
Im searching in a database through ASP in a field called description which has a sentance e.g. "This is a video of a brick layer laying brick" , i need to do a search so when i search for "brick" or "bicks" that particular sentance appears insteasd of all of them appearing this is what i have so far.

sqlStatment = sqlStatment + "SELECT * FROM Videos "
sqlStatment = sqlStatment + "WHERE Description = '%"& varsearch1 &"%'"

I can do other searches when the field only has 1 word, but i need it to search through multiple words and find that one.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-06 : 05:44:14
Maybe you shold try out FULLTEXT search?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2007-09-10 : 10:11:47
Hi dizzy1,

Could u tell exactly what u need?
U want to search by more than one word ?
or U want to get back the particular sentence containing a word ?

Also note that ur SQL may not work because of the = operator, instead u have to put "Like"

U may try

sqlStatment = sqlStatment + "SELECT * FROM Videos "
sqlStatment = sqlStatment + "WHERE Description Like '%"& varsearch1 &"%'" or Description Like '%"& varsearch2 &"%'"






Srinika
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-09-10 : 10:29:36
You should use full text search if you have lots of data. But if not, you can use something like this:

http://weblogs.sqlteam.com/jeffs/archive/2004/11/02/2460.aspx

Also -- be sure to always use parameters, never concatenate together a sql string like that!


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -