I
started as web developer about 1 year ago. Since then I've gone through PHP, mySQL,
Javascript, jQuery, etc. I think I've learned some things in this time. But when it
comes to SQL I'm a real noob. I just do a couple of SELECT, INSERT, UPDATE, and using
some functions like SUM or UNIX_TIMESTAMP,
etc.
I've come across the JOIN functions, and it
seems to be pretty useful, but I don't see the difference of using JOIN or some WHERE
clauses to "join" the data betwwen tables.
I
read href="http://mauriciopastrana.com/gadgets-y-tecnologia/entendiendo-los-mysql-join/"
rel="nofollow noreferrer">this article (spanish) about join. and I can't
really see the usefulness of it. For
example:
Assuming this
dataset:
id nombre id
nombre
-- ---- -- ----
1 Pirata 1 Rutabaga
2
Mico 2 Pirata
3 Ninja 3 Darth Vader
4 Spaghetti 4
Ninja
Wouldn't this
query: SELECT * FROM TablaA INNER JOIN TablaB ON TablaA.name =
produce the same results as
TablaB.nameSELECT * FROM TablaA,
?
TablaB WHERE TablaA.name = TablaB.name
Answer
Yes, they will produce the same result,
however, SELECT * FROM TablaA, TablaB WHERE TablaA.name =
is an older method of performing a join that does not meet the
TablaB.name
SQL-92 standard. It is also a lot more difficult to read once your queries start to
become very complex. It is better to stick with the explicitly declared INNER JOIN
format.
No comments:
Post a Comment