Hi.

On Sat 2002-07-20 at 22:23:06 -0700, [EMAIL PROTECTED] wrote:
> And could not find where or if they have archives of the list for my to
> search though so I guess I will ask my question.

Some searchable archives can be found here:
http://www.mysql.com/documentation/searchlists.html

> I was wondering how to go about joining 3 tables. I figured out how to
> join 2 took me about 30 min to get it to join right, but I cant for the
> life of me figure out 3.
> 
> Here are the SQL statements I have tried
[...]

You are mixing INNER JOINs with LEFT JOINs and so on. Is this
intention (as you did not mention it initially)?

> SELECT twc_loot_distro.*, twc_mob_loot.loot_name 
> FROM twc_loot_distro 
> INNER JOIN ( 
>               SELECT twc_loot_distro.*, twc_mob_list.mob_name
>               FROM twc_loot_distro
>               LEFT JOIN twc_mob_list
>               ON twc_loot_distro.mob_id=twc_mob_list.mob_id 
>               ) 
> ON twc_loot_distro.loot_id=twc_mob_loot.loot_id

This tries something like a sub-select, which is not supported by
MySQL yet (don't know if the syntax would be legal with other RDBMS).

[...]
> SELECT twc_loot_distro.*, twc_mob_list.mob_name, twc_mob_loot.loot_name
> FROM twc_loot_distro
> LEFT JOIN twc_mob_list, twc_mob_loot
> ON twc_loot_distro.mob_id=twc_mob_list.mob_id AND
> twc_loot_distro.loot_id=twc_mob_loot.loot_id

This one was close. Just keep the ON clauses seperate. And "," as JOIN
operator does not expect an ON clause, so either use INNER JOIN again
or write the condition in the WHERE clause. The working example is
(as near to your example as possible)

  SELECT twc_loot_distro.*, twc_mob_list.mob_name, twc_mob_loot.loot_name
  FROM   twc_loot_distro
         LEFT JOIN twc_mob_list ON twc_loot_distro.mob_id=twc_mob_list.mob_id 
         , twc_mob_loot
  WHERE  twc_loot_distro.loot_id=twc_mob_loot.loot_id

Or with INNER JOIN

  SELECT twc_loot_distro.*, twc_mob_list.mob_name, twc_mob_loot.loot_name
  FROM   twc_loot_distro
         LEFT JOIN twc_mob_list ON twc_loot_distro.mob_id=twc_mob_list.mob_id 
         INNER JOIN twc_mob_loot ON twc_loot_distro.loot_id=twc_mob_loot.loot_id

Greetings,

        Benjamin.

-- 
[EMAIL PROTECTED]

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