1

I'm learning SQL, and the chapter talks about joining tables like this

SELECT 
    P_DESCRIPT, P_PRICE, V_NAME, V_CONTACT, V_AREACODE, V_PHONE`
FROM 
    PRODUCT, VENDOR
WHERE 
    PRODUCT.V_CODE = VENDOR.V_CODE;

However, when I look up additional information on joins on the web, I see the JOIN clause with inner and outer joins and so on, which is fine, but then is using the FROM clause considered a join or not? Or is this simply an out of date way doing joins?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    It is considered archaic syntax for a join. I would suggest that you find more modern materials. `JOIN` has been around since the 1990s. – Gordon Linoff Jul 10 '20 at 19:06
  • 1
    Using JOIN is preferred and recommended way. Read more on that. – switch Jul 10 '20 at 19:30
  • Does this answer your question? [In MySQL queries, why use join instead of where?](https://stackoverflow.com/questions/2241991/in-mysql-queries-why-use-join-instead-of-where) – Nickolay Jul 10 '20 at 19:30
  • Those are called a "SQL-89 joins", aka "the old join syntax". They became obsolete with SQL-92 (28 years ago). They are limited in functionality, difficult to read and to debug. I would suggest getting a better textbook. What's the book name, out of curiosity? – The Impaler Jul 10 '20 at 19:34
  • I suspected that was the case, I cant find the exact textbook reference anymore, but it is from the uCertify material, course called _Database Management Foundations_ – TheDeanMachine Jul 10 '20 at 21:25

3 Answers3

0

To answer your question, no, they are not the same thing.

The "SQL-89 joins" you mention are limited in functionality compared to SQL-92 joins (the JOIN clause) since they don't include outer joins. Moreover, they are difficult to read and to debug.

The Impaler
  • 45,731
  • 9
  • 39
  • 76
0

This is the preferred format (note - made the table aliases longer for clarity):

SELECT 
    prod.P_DESCRIPT, prod.P_PRICE, vend.V_NAME, vend.V_CONTACT, vend.V_AREACODE, vend.V_PHONE`
FROM 
    PRODUCT prod 
JOIN VENDOR vend on vend.VENDOR.V_CODE = prod.PRODUCT.V_CODE
WHERE 
< other conditions etc...>
;

If you want to compare your "from" version vs the "join" version you can use your SQL workbench tool of choice profiler to run the execution plan to see which is more efficient.

Ken
  • 526
  • 6
  • 13
0

In the query provided by you, we can consider as two tables are first cross-joined and then we are providing a condition in the WHERE clause to filter the output of the cross join result.

Prakhar Gupta
  • 471
  • 5
  • 11