> Here's the situation:
>
> table: books
> ----------------------------------------------------
> |BookNumber |Author |Title | ....
> ----------------------------------------------------
> | ... | | |
> | 312 |'TWAIN, MARK' |'Huckleberry Finn' |
> | ... | | |
> ----------------------------------------------------
<cut>
> table: words
> -------------------------
> |WordNumber |Word |
> -------------------------
> | ... | |
> | 457 | 'Finn' |
> | ... | |
> |------------------------
<cut>
> table: wordlinks
> --------------------------
> |WordNumber |BookNumber |
> --------------------------
> | ... | |
> | 457 | 312 |
> | ... | |
> |-------------------------
<cut>
> When I search for a title or a couple of keywords, a search
> is done in the words table to retrieve the associated WordNumber
> values.
> Secondly, these WordNumber values are searched in the wordlinks
> table, and the associated BookNumber values are retrieved.
> Only the BookNumber values which appear for each searched word
> are retrieved.
> Thirdly, the books are then located by BookNumber and
> displayed in a search result.
>
> My question is:
>
> Is this three stage action possible with one SQL statement?
I would try something like:
SELECT DISTINCT books.*
FROM books, words, wordlinks
WHERE (books.BookNumber = wordlinks.BookNumber) AND
(wordlinks.WordNumber = words.WordNumber) AND
( (words.Word = 'word1') OR (words.Word = 'word2') OR ... )
/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php