I'm not sure if you're a novice to databases in general or just MySQL but if
you aren't quite sure what a join is, I suspect you must be new to
relational databases in general.

In that case, may I recommend that you seriously consider devoting some time
to learn SQL? This is the language used by all of the relational databases -
and many non-relational databases as well - and it will pay you big
dividends to know the language as you continue your work with MySQL.

There are lots of ways to learn SQL:
- online tutorials (just Google on 'SQL tutorial' and you should find a
bunch)
- books
- classroom courses

Also, the product manuals for some databases come with SQL tutorials. The
MySQL manual is not particularly good at teaching SQL but IBM makes a decent
effort with their DB2 manuals and the SQL they use is virtually identical to
the MySQL dialect of SQL because they both try to conform to the same
standards.

Rhino

----- Original Message -----
From: "Perry Merritt" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Wednesday, April 20, 2005 11:36 PM
Subject: many to many


> 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


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to