Querying and showing a many-to-many rel.

wxdqz

New Member
I have the "usual" many to many relationship between two tables:
Table1: Id-Book, Title
Table2: Id-Keyword, Keyword
Table3: Id-Book, Id-Keyword

what i am looking for is a way to show something like:

Title1 - Keyword1,Keyword2,Keyword3
Title2 - Keyowrd1,Keyword4,Keyword5
Title3 - Keyword2,Keyowrd5
Title4 - Keyword3,Keyword6,Keyword7,Keyword8
...

in an efficient way. The user searching for all the books having one or more keywords should be able to see the list of related titles and ALL the keywords relative to those titles... the problem is of course that in a table like that every row should have a different number of columns. The only thing i can think of is first retrieving all the titles related to the desired words ( i can do that ) and then a query for every title to retrieve all the keywords... but this is pretty unefficient if i have 5.000 titles !

Thanx for all ur help !

Emiliano
 
Back
Top