Hi Justin,

> ...the docs to be looking for examples.
>
> I have three tables...
> cd (id, title, etc)
> artist (id, name)
> cd_to_artist (cdid, artistid)
> Given an artist id, I want to retrieve all cds related to that artist,
given
> the information in the table cd_to_artist.  The reason for the third table
> is because more than one artist can be related to a CD (compilations,
etc).
>
> Should I be looking at JOIN? or is it something more complex in the WHERE,
> or am I way off track?

=Some people think that joins are established at TABLE CREATE time. In MySQL
they are established (dynamically) at SELECT (query) time.

=Yes you should be looking at joins, and yes it could be the WHERE clause -
so you're on the right track. There are two forms of join: the
oldest/traditional in the WHERE clause, eg WHERE cdid = cd.id; and the
second (SQL92) format when you can actually see the word JOIN being used, eg
FROM cd LEFT JOIN cd_to_artist ON...

> Any links to articles, FAQs, etc etc, or query snippets would be greatly
> appreciated...  I'm using MySQL in conjunction with PHP if that helps...

=makes no difference to the SQL logic.

=SitePoint's Kevin Yank's article on joining (pun) PHP and MySQL is one of
the 'standards'. There are many tutorials for MySQL specifically (start at
manual Chap3, or web site for links page) and for SQL generally. Any search
engine will overwhelm you with 'hits'.

=Regards,
=dn



---------------------------------------------------------------------
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

Reply via email to