If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Which is the better MySQL statement?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-11, 11:05
Rai_Yan Rai_Yan is offline
Registered User
 
Join Date: Jan 2011
Posts: 2
Which is the better MySQL statement?

Hi, Iv'e been using MySQL for sometime now and I am searching for the best statements to solve my problem.

I tested two statements below in MySQL Browser and each yield the same result. (Primary key: tbl_client.id_Client, Foreign key: tbl_order.id_Client) The first one is commonly used while the second one is the format I am more comfortable with. Does any of you knows which one is actually better? In performance issue perhaps...

---------------------------------------------------------

SELECT tbl_client.Last_Name, tbl_client.First_Name
FROM tbl_client
INNER JOIN tbl_order
ON tbl_client.id_Client=tbl_order.id_Client
WHERE tbl_order.Status=1

---------------------------------------------------------

SELECT C.Last_Name, C.First_Name
FROM tbl_client AS C, tbl_order AS O
WHERE C.id_Client=O.id_Client AND O.Status=1

---------------------------------------------------------

Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-11-11, 11:42
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
first one is much, much better, if your question concerns join syntax

second one is better, albeit not by much, if your question concerns table aliases

bofadem fail the table name criterion of clarity (i.e. if you're gonna call the tables "tbl_something" then why don't you call the columns "col_something" as well)

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-12-11, 13:24
Rai_Yan Rai_Yan is offline
Registered User
 
Join Date: Jan 2011
Posts: 2
Quote:
Originally Posted by r937 View Post
first one is much, much better, if your question concerns join syntax

second one is better, albeit not by much, if your question concerns table aliases

bofadem fail the table name criterion of clarity (i.e. if you're gonna call the tables "tbl_something" then why don't you call the columns "col_something" as well)

Yeah, my table naming is a fail... but then I am the only ones who read them anyway and its pretty clear from here.

Back to my original concern... How about performance? Efficiency between two codes? You know anything about it?
Reply With Quote
  #4 (permalink)  
Old 01-12-11, 13:37
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
Quote:
Originally Posted by Rai_Yan View Post
Efficiency between two codes? You know anything about it?
some

for all your tents and porpoises, they perform the same

this can ~not~ be said, however, if you want a left outer join instead of an inner join

then they are uncomparable
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On