Need help with SQL
Posted in 1995
Topics: SQL Development & Query Writing, Connectivity: ESQL/C, 4GL & Embedded SQL
Hello out there,
could someone of you help me to formulate a SQL query?
I will just tell you my problem:
Assume two tables.
a) Table DOCS with document descriptions:
DOCS: DOC_ID | other info (of no interest here)
====================
1 | ...
2 | ...
3 | ...
... | ...
b) Table INDX with indexterms of documents:
INDX: TERM | DOC_ID
================
aaaa | 1
dddd | 1
eeee | 1
ffff | 1
hhhh | 1
----------------
cccc | 2
dddd | 2
ffff | 2
gggg | 2
----------------
aaaa | 3
bbbb | 3
eeee | 3
.... | ...
The indexterms of documents shall be computed automatically
and each document might be labeled with an arbitrary number
of indexterms. The table INDX keeps these terms and gives
the document_id's of each term. A term might also belong
to several different documents.
Query part one:
select * from DOCS where (informal condition follows)
First query condition:
each single word of a list of words is attached to
the desired document
Second query condition:
at least one word of a list of words is attached to
the desired document
For the second query I helped myself with a generated SQL
query (I am working with ESQL/C):
where ((INDX.DOC_ID = DOCS.DOC_ID) and
INDX.TERM in (<list of terms>));
If you could help me in any way, I would like you to send
me an e-mail message, since we sometimes have problems with
news.
Thanks in advance...
...Thomas
--
--------------------------------------------------------
Thomas Kieninger
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz
DFKI-GmbH Tel: +49-631-205-3485
Postfach 2080 Fax: +49-631-205-3210
67608 Kaiserslautern, FRG E-Mail: kieni@dfki.uni-kl.de
WWW: http://www.dfki.uni-kl.de/~kieni/cv.html