Go Back   SitePoint Forums > Forum Index > Program Your Site > Databases > MySQL
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Apr 21, 2006, 00:42   #1
dotJoon
Get my greedy down
 
Join Date: Apr 2003
Location: daejeon, South Korea
Posts: 1,753
join and inner join

Code:
myTable24

(m) id
(1) Tom 
(2) Kojack 
(3) Jimmy 
(4) Mary 

myTable25

(s) top          say                            tm
(1) America    I like America                    1
(2) France     I am from France                  4
(3) 1          I visited New York yesterday      3
(4) China      China is good                     3
(5) 1          Chicago is a city                 2
(6) 2          Paris is beutiful                 1
I have myTables like the above.

Code:
code1

select s, top, say, tm,id

from myTable25
join  myTable24 on tm=m

where id like '%#variables.w#%'


code2
select s, top, say, tm,id

from myTable25
inner join  myTable24 on tm=m

where id like '%#variables.w#%'
The both code1 and code2 have the same results.

What is the different between join and inner join or which is correct?
dotJoon is offline   Reply With Quote
Old Apr 21, 2006, 04:02   #2
r937
SQL Consultant
silver trophybronze trophy
SitePoint Award Recipient
 
r937's Avatar
 
Join Date: Jul 2002
Location: Toronto, Canada
Posts: 31,026
Quote:
Originally Posted by joon
What is the different between join and inner join or which is correct?
there is no difference

in recent versions of mysql, INNER is an optional keyword, but in earlier versions, if you didn't say INNER, you ended up getting a CROSS JOIN

this is why i always recommend using the optional keywords anyway -- it adds to clarity, and avoids problems

so, always say INNER JOIN instead of JOIN, and always say LEFT OUTER JOIN instead of LEFT JOIN
r937 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:26.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved