List:General Discussion« Previous MessageNext Message »
From:Uttam Date:April 25 2003 5:39am
Subject:RE: INNER JOIN? Was: Can I do two LEFT JOINs in one SELECT?
View as plain text  
yes,
	FROM company_table INNER JOIN dept_table ON company_id =
dept_company_table_id
is same as
	FROM company_table, dept_table WHERE company_id = dept_company_table_id

however, you have to mentioned join conditions & join types explicitly when
you are making multiple joins like the one in your query.

I prefer using INNER JOIN syntax over ',' because it makes sql code clear
and explicit and also separates join condition from where conditions.

read more at http://www.mysql.com/doc/en/JOIN.html

regds,

-----Original Message-----
From: Daevid Vincent [mailto:daevid@stripped]
Sent: Friday, April 25, 2003 03:27
To: 'Uttam'; mysql@stripped
Subject: RE: INNER JOIN? Was: Can I do two LEFT JOINs in one SELECT?


You rock... While I had to message it a bit, to be like this:

mysql> SELECT rep_fname, rep_lname, dept_name, contact_fname,
contact_lname
    -> FROM company_table INNER JOIN dept_table ON company_id =
dept_company_table_id
    ->  LEFT JOIN contact_table ON dept_id = contact_dept_table_id
    ->  LEFT JOIN rep_table ON dept_rep_table_id = rep_id
    -> WHERE company_id = '20'
    -> ORDER BY dept_name;
+-----------+-----------+---------------------+---------------+---------
----
--+
| rep_fname | rep_lname | dept_name           | contact_fname |
contact_lname |
+-----------+-----------+---------------------+---------------+---------
----
--+
| Daevid    | Vincent   | --N/A--             | daevid        | vincent
|
| Daevid    | Vincent   | --N/A--             | jim           | sawicki
|
| Daevid    | Vincent   | No Name Dept        | Eric          | Johnson
|
| NULL      | NULL      | NULL Rep Department | NULL          | NULL
|
+-----------+-----------+---------------------+---------------+---------
----
--+
4 rows in set (0.00 sec)


Now, can you tell me what that INNER JOIN is and why you used it? Is
that
the same as
 FROM company_table, dept_table WHERE company_id = dept_company_table_id
[However replacing that in the example above didn't work]

http://exchange.manifold.net/manifold/manuals/5_userman/mfd50INNER_JOIN_
Oper
ation.htm

Says it's the most common join, but I thought that STRAIGHT JOIN or
simply
"," was?

And the attached link makes no mention of INNER JOINs


Thread
Can I do two LEFT JOINs in one SELECT?Daevid Vincent24 Apr
  • RE: Can I do two LEFT JOINs in one SELECT?Uttam24 Apr
    • RE: INNER JOIN? Was: Can I do two LEFT JOINs in one SELECT?Daevid Vincent24 Apr
  • Re: Can I do two LEFT JOINs in one SELECT?Brent Baisley24 Apr
  • Re: Can I do two LEFT JOINs in one SELECT?Joshua J . Kugler24 Apr
RE: INNER JOIN? Was: Can I do two LEFT JOINs in one SELECT?Uttam25 Apr