Hi
SELECT b.* //all fields from builder
FROM
builder b //define tables and aliases
, builder_category_link l
, category c
WHERE
(b.builderID = l.builderID) //linking builder to link table
AND (l.categoryID = c.categoryID) //linking category to link table
which in
//turn builds the link to the
builder table
AND (l.category_description = 'plumber'); //where category is plumber
should return all builders who do plumbing
I think the id field in the link table is redundant, unless you have another
use for it.
Hope I understood what you were aiming to do :)
Peter
-----------------------------------------------
Excellence in internet and open source software
-----------------------------------------------
Sunmaia
www.sunmaia.net
[EMAIL PROTECTED]
tel. 0121-242-1473
-----------------------------------------------
> -----Original Message-----
> From: bob [mailto:[EMAIL PROTECTED]]
> Sent: 13 June 2002 17:09
> To: [EMAIL PROTECTED]
> Subject: Help needed with JOIN on 3 tables
>
>
> Hi,
>
> I'm very new to mysql and I'm having a problem getting my joins to work. I
> have 3 tables:
>
> builder
> category
> builder_category_link
>
> The builder table has a an id field and then several other fields (name,
> address etc)
> The category table has an id field and then one other field (type of
> business... electrician, plumber etc)
> The builder_category_link table has 3 fields, an id and then a
> builderid and
> a categoryid (links the other two tables together)
>
> So, I can have a builder that can be a plumber, an electrician etc, etc.
>
> I've tried every way I can think to get the join to work and I've read and
> re-read the mysql docs and
> I just can't figure out how to make it go. I want to be able to search on
> both builder name and category
> (and get the builders that are in that category).
>
> Thanks for your help.
>
> Rob.
>
>
>
> ---------------------------------------------------------------------
> 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
>
---------------------------------------------------------------------
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