473,387 Members | 1,495 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.

Need help with SQL query. Keyword matching.

Hi all,

I have two tables:

workgroups (wg_id, wg_name)
workgroups_keywords (wgk_wg_id, wgk_keyword)

Each workgroup has an associated list of one or more keywords.

What I want do to at first was given a particular list of keywords
bring back a list of workgroups that have at least one matching keyword
associated with it.

I have the following query:
select distinct(wg_id), wg_name
from workgroups, workgroups_keywords
where
wgk_keyword in (#QuotedValueList(Keywords.wgk_keyword)#)
and
wg_id = wgk_wg_id
order by wg_name

This works great.

However, is there a way in a single query to order the returned rows by
the number of keywords that are found to be matching (in other words an
order by relevancy, the more keywords that match the more relevant the
returned row)?

Thanks in advance.

David

Jul 27 '05 #1
2 3055
(da***@iaction.com) writes:
I have two tables:

workgroups (wg_id, wg_name)
workgroups_keywords (wgk_wg_id, wgk_keyword)

Each workgroup has an associated list of one or more keywords.

What I want do to at first was given a particular list of keywords
bring back a list of workgroups that have at least one matching keyword
associated with it.

I have the following query:

select distinct(wg_id), wg_name
from workgroups, workgroups_keywords
where
wgk_keyword in (#QuotedValueList(Keywords.wgk_keyword)#)
and
wg_id = wgk_wg_id
order by wg_name
This syntax looks funny to me. Are you really using Microsoft SQL Server?
This works great.

However, is there a way in a single query to order the returned rows by
the number of keywords that are found to be matching (in other words an
order by relevancy, the more keywords that match the more relevant the
returned row)?


That sounds doable. It would be something like

SELECT wg_nmae, COUNT(*)
FROM ...
GROUP BY wg_name
ORDER BY 2

But since I don't know exactly how this Keywords.wgk_keyword works,
and I'm uncertain that you are using MS SQL Server, I refrain from a
complete answer.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 27 '05 #2
On 27 Jul 2005 08:50:27 -0700, da***@iaction.com wrote:
Hi all,

I have two tables: (snip)Thanks in advance.

David


Hi David,

You posted the same question in microsoft.public.sqlserver.programming,
where it was answered. Please don't post the same question to multiple
groups. Posting to one group is the preferred method. And if you really
feel that the question belongs in two groups, then please usse your
software's crossposting facility to get the same message in both groups,
so that replies in one group will also be visible in the other. That
saves other people from spending time and energy to answer a question
that is already answered elsewhere.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 27 '05 #3

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

Similar topics

3
by: JT | last post by:
I have a MySQL fulltext search form in place and I now want to filter the results further. I've added a few multiple select boxes on my form (ResourceType and Topic), and I'm able to build and...
1
by: David C. Barber | last post by:
I'm trying to determine if any matching records exist on a LIKE query performing a partial match of last names to a remote back-end database in the most efficient manner possible. LAN Traffic...
3
by: Roy W. Andersen | last post by:
Hi, I need to do some replace-calls on certain strings in order to replace smiley glyphs and other keywords with graphical icons on the client. Unfortunately, my knowledge of regular expressions...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
6
by: Hemant Shah | last post by:
Folks, I am having trouble with a query. DB2 does not use index, it does relation scan of the table. I am running DB2 UDB 8.2 on Fedora Core release 4 (Stentz) # db2level DB21085I ...
9
by: neelesh kumar | last post by:
sir, suppose if the question is how many stations are there ,then if i give some word matching the question in table in the textbox named keyword ,i want to get that question docmd.applyfilter...
5
by: Samik2003 | last post by:
Hello, The problem is my query is not extracting the correct xml data from the database : Is there something which I am missing?? ANy help would be appriciated. Thanks, Sam. THis is the...
2
by: pjamrisk | last post by:
Hi, I was wondering if one of the many guru's my help me out. Through several javascript books we have been trying to make an autocomplete feature for our department website for certain fields from...
1
by: Donald Calloway | last post by:
I have created a database application that uses a macro, activated by a button click event, that runs a query which returns a recordset consisting of a subset of the matching database record, and...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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.