473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Searching problem

Hi! I'm working with a database of news clippings. The database has
fields for the title of the article and the text of the article (also
other fields for things like sources and categories, but those have no
relevance to the question).

We have a single search box that normally searches both the title field
and the body text field (with wildcard characters: '%SEARCH_STRING%').

What I want is for the search results to be ordered so that matches in
the title field come first (and this section is ordered by an ORDER
clause, i.e. by Date or by topic, etc.) then matches from the body text
field (again this section ordered by an ORDER clause).

If this is possible, I'd like to know if this can all be rolled into a
single SQL statement so that ADO through ASP can handle all the paging
for me. I know this isn't the listerv for it but if this can't be
rolled into a single SQL statement, does anyone here happen to know ASP
(in VB Script, no C#...)/ADO well enough to tackle the problem?

Thanks guys!

Daniel Cousineau
dc********@gmail.com

Sep 27 '06 #1
2 1568

dcousin...@gmail.com wrote:
Hi! I'm working with a database of news clippings. The database has
fields for the title of the article and the text of the article (also
other fields for things like sources and categories, but those have no
relevance to the question).

We have a single search box that normally searches both the title field
and the body text field (with wildcard characters: '%SEARCH_STRING%').

What I want is for the search results to be ordered so that matches in
the title field come first (and this section is ordered by an ORDER
clause, i.e. by Date or by topic, etc.) then matches from the body text
field (again this section ordered by an ORDER clause).

If this is possible, I'd like to know if this can all be rolled into a
single SQL statement so that ADO through ASP can handle all the paging
for me. I know this isn't the listerv for it but if this can't be
rolled into a single SQL statement, does anyone here happen to know ASP
(in VB Script, no C#...)/ADO well enough to tackle the problem?

Thanks guys!

Daniel Cousineau
dc********@gmail.com
Just order it by some statement that returns either 1 or 0 depending on
where the match is. "case" should do the trick:

select ...
from someTable
where (headline like '%searchString%' or body like '%searchString%')
order by (case when headline like '%searchString%' then 0
else 1 end), postDate, topicName, etc.

Sep 27 '06 #2
Thanks!

ZeldorBlat wrote:
dcousin...@gmail.com wrote:
Hi! I'm working with a database of news clippings. The database has
fields for the title of the article and the text of the article (also
other fields for things like sources and categories, but those have no
relevance to the question).

We have a single search box that normally searches both the title field
and the body text field (with wildcard characters: '%SEARCH_STRING%').

What I want is for the search results to be ordered so that matches in
the title field come first (and this section is ordered by an ORDER
clause, i.e. by Date or by topic, etc.) then matches from the body text
field (again this section ordered by an ORDER clause).

If this is possible, I'd like to know if this can all be rolled into a
single SQL statement so that ADO through ASP can handle all the paging
for me. I know this isn't the listerv for it but if this can't be
rolled into a single SQL statement, does anyone here happen to know ASP
(in VB Script, no C#...)/ADO well enough to tackle the problem?

Thanks guys!

Daniel Cousineau
dc********@gmail.com

Just order it by some statement that returns either 1 or 0 depending on
where the match is. "case" should do the trick:

select ...
from someTable
where (headline like '%searchString%' or body like '%searchString%')
order by (case when headline like '%searchString%' then 0
else 1 end), postDate, topicName, etc.
Oct 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: jblazi | last post by:
I should like to search certain characters in a string and when they are found, I want to replace other characters in other strings that are at the same position (for a very simply mastermind game)...
3
by: hivie | last post by:
I have a problem that is causing me problems. I have a text file that stores 5 lines of crap (stuff that I dont need( for the user only)). After that there is data that is in three columns...
2
by: Michi | last post by:
Hello, I am creating a databse with a large number of text (or blob?) entries. I want users to be able to search these fields. An example would be a forum or journal. Indexing every word in...
0
by: Chris Chandler | last post by:
Hello I am developing a web application that uses full text searching quite extensively. This is ideal where I am searching a large number of large varchar fields for a set of key words. My...
10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
4
by: James | last post by:
We have a need to search through an entire drive for a specific file name. The process is currently written with recursive loops through each directory and the Scripting.FileSystemObject. Problem...
3
by: Gary | last post by:
I notice that using XP for searching through a project for strings does not work, as it did in Win2k. It can't seem to find stuff in VB or aspx or much else. Can this be fixed somehow? Is it an...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
1
by: alamodgal | last post by:
hiiiiiii I have a problem in highlighting searching keyword.Actually im using this function for searching Public Function HighLight(ByVal Keyword As String, ByVal ContentFor As String) Dim...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.