Hello,

Have 3 tables.
equities
--------
equityID
symbol

keywords
--------
keywordID
keyword

keyword_equity_join
----------------------------
keID
equityID
keywordID

The user selects from a dropdown list a keyword
The user may then add another dropdown list to select another keyword.
The user may add as many dropdown list as he or she wants.

When the user clicks on the submit button I have a list of keywords.
If the keywords happen to be: technology, consulting.
I want the query to return only the symbols that have both technology and
consulting as associated keywords.

So far this is what I have (doing it in Query Analyzer before writing the
code).

select e.symbol, kej.keywordID, e.equityID
from equities as e, keyword_equity_join as kej
where e.equityID = kej.equityID and
  kej.keywordID in (

select k.keywordID
from keywords k
where (keyword = 'technology' OR keyword = 'consulting')
)

select k.keywordID
from keywords k
where (keyword = 'technology' OR keyword = 'consulting')

This returns the keywordID for the two keywords.

select e.symbol, kej.keywordID, e.equityID
from equities as e, keyword_equity_join as kej
where e.equityID = kej.equityID and
  kej.keywordID in (

This returns all the symbols that are associated with either keywords.
Results
------------
ABCO    355    11391
RADS    355    11138
XPRT    355    14160
RCMT    65    11022
ACLA    65    12237
ACN    355    13256
ACN    65    13256
ACOC    355    16491

I just want ACN.

Anyone have experience with this?
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to