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)
 any sql code to search database tables

Author  Topic 

mentor
Starting Member

4 Posts

Posted - 2008-07-18 : 21:10:17
I want to add a searching function in my website, to search product stored in a table in sqlserver 2005. The keyword may contain some special character like --,(,), etc. The codes I compiled won't work well.

Is there any open source code with such functionality? code for mysql is also welcome :) thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-18 : 21:32:00
Are you using mysql or Microsoft SQL Server ?

Also post the query you used here (if you are using SQL Server).


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-07-18 : 22:04:10
See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q178070
Go to Top of Page

mentor
Starting Member

4 Posts

Posted - 2008-07-19 : 02:36:07
I'm now using sqlserver2005 for present.
The table in database contains books information, including tilte,author,publisher,isbn etc. User may search these fields.
For simplicity,now suppose the user searches only title field.
The target book is "Brown Bear, Brown Bear, What Do You See? (Board book)".
The user may input correct complete query as "Brown Bear, Brown Bear, What Do You See? (Board book)",
but may also input something like " Brown Bear--Waht do you see", "Brown Bear,my friends".

In these cases, I'd like the user get the correct result, also any related topic with similiar keyword could be returned, like book "Habits of Brown Bear".

Any experieces to help this task ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-19 : 02:39:34
You can use FULLTEXT engine.



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

mentor
Starting Member

4 Posts

Posted - 2008-07-19 : 03:23:36
Yes, I'm using fulltext catalogue. But there would be error prompt if I don't process the special characters. I think, there two aspect with this problem,

1) Handling of special character ( should I strip them ?);
2)Searching Logic, or Handling or query keyword, to give more result, with best mathes first.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-19 : 04:01:16
What is your "special" characters that FULLTEXT doesn't like?


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

mentor
Starting Member

4 Posts

Posted - 2008-07-19 : 04:38:54
For example, I input (Board book), an erro prompt syntax error near ')'. Maybe it interfered fulltext's contain method ?
Go to Top of Page
   

- Advertisement -