Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retrieve combined row values?

Status
Not open for further replies.

mikerobb

Programmer
Nov 7, 2001
13
0
0
US
Here is my table setup:


table_1:
tag int(16) pri
data blob

table_2:
word varchar(20) pri
tag int(16) mul
weight int(16)


Query:
Trying to find (by order of weight) strings that match 'word'.


Example (This works):

SELECT W.tag,W.word,W.weight,N.tag,N.data
FROM table_1 AS N, table_2 AS W
WHERE W.tag like N.tag AND W.word like 'baseball'
ORDER BY W.weight DESC;



What I want to do is be able to find table_1.blob where multiple keywords (table_2.word) are found.
Futher, I want to order the results based upon the combined weight of all the keywords found.
If the keywords searched for are not all matched - then no results should be found.

Example (This returns results, but not what I want):

SELECT W.tag,W.word,W.weight,N.tag,N.data
FROM table_1 AS N, table_2 AS W
WHERE W.tag like N.tag AND (W.word like 'truck' OR W.word like 'ball')
ORDER BY W.weight DESC;


The question is how can I find one tag number that has the cooresponding tags?

-TIA!



 
hmmm... could we see some example rows from each table?

rudy

;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top