Hi, I'm a novice.
I've designed a database that supports many to many relationships (actually many to many
to many) and I need help creating the query to find my data. I know things like JOINs
exist, but don't have a clue how to use them.
I have three main tables and two link tables, The main tables are A, B, and C. Each are
defined with id INT and word VARCHAR(32); The link tables are X and Y. X links A and B
with the columns a_id and b_id. Y links the tables B and C with columns b_id and c_id.
Here's what I want to accomplish:
Get the A.id where A.word = "some value"
Use A.id to search X where X.a_id=A.id (from above)
Use all occurences of X.a_id = A.id to select word from B using B.id=X.b_id
AND finally,
select C.id where C.Word = "Some other value"
and given Y.c_id = C.id use the matching Y.b_id to further limit the select on B.word
Can this convoluted mess be understood and if so, can a single query pull it off?
I'm implementing this in perl, so I can break the queries into pieces if I absolutely have
to.
Thanks
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com