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 |
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2005-10-21 : 07:01:04
|
| hi AllMy next thing is to build a search form for my site. And I wanted to discuss with you how I should do it.(1) Sometimes when you search on some websites, the search result is displayed according to table names. So you may get:Products - 5 results are foundNews - 2 results are foundMy question is: how do I know how many results are found for which table.- Do I separately run search query for different tables. e.g. first search in the Products table, then run a separet query for News table??- Is it possible to return Table name with the search query?- How do I write the query so I know how many results are found for each table.(2) I have been asked to remove funny characters, spaces, and commas from the search string. Is this possible with SQL, or is this more to do with VB/ C# programming.(3) There is a single text box for the users to type in their search string. I have been asked that I need to break the user's search string into separate words. So if the user enters: "This is my search query", I need to break it into: "This" "is" "my" "search" "query" and then search for all these words.- Can I break a string into separet words using SQL?- If I have to break the search string using a programming language, I would have to run the search query for each word. If I run the search query for each word, How do I combine the search result for the user. For instance, if I search for "my" and find some result, then search for "search" and find some results, how do I display a SINGLE search result to the user.It has become a lengthy post, but I hope someone will have some suggestions.regards |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-10-21 : 08:28:30
|
1) I would query each table seperately (still in one proc of course) if they are seperate types of results (you could also pass a param to choose a specific type or all if desired)1)a) If you put each set of results into a temporary table, you can tag each of the records with the table that it came from. then querying the count(*) of each tag will tell you how many came from where2) Read this post(http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56713)... it should strip anything you want3) Check out split functions (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648)... you could probably just split on ' '.Hope that helps!Corey Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..." |
 |
|
|
hasanali00
Posting Yak Master
207 Posts |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-10-21 : 17:09:44
|
you probably want: Select dbo.GetCharacters(@TestStr,'0-9a-z ')will return alpha/numerics & spacesyou may want to add '.', '"', etcCorey Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..." |
 |
|
|
|
|
|
|
|