Join tables or select from multiple tables

What is better between joining a table or choosing from multiple tables?

For example, suppose the following scenario:

Using join :

SELECT COALESCE(SUM(SALARY),0) FROM X JOIN Y ON X.X_ID=Y.Y_X_ID 

OR

Under a choice of several tables

 SELECT COALESCE(SUM(SALARY),0) FROM X, Y WHERE X.X_ID=Y.Y_X_ID 
+6
source share
3 answers

basically a connection is used to extract data from several tables so in sql there are 3 types of connections available

  • Combining with Equi Link Outer Link-Left Correctly Complete
  • Non equi join
  • Join
  • Cross join
+2
source

You can use the JOIN syntax for many reasons, which can be found here .

In addition, this syntax has the advantage of giving some hints to the query optimizer (when calculating weights, the weights calculated directly by the facts mentioned in this syntax are more advantageously weighted than others).

+1
source

Both are unions. The first is an explicit join, and the second is an implicit join and is an SQL antipater.

The second is bad because it is easy to get a random cross join. This is also bad, because when you want to cross-connect, it is unclear whether you want this or if you have a random one.

Further in the second style, if you need to convert to an external connection, you need to change all the connections in the query or get the wrong results. Thus, the second style is more difficult to maintain.

Explcit joins were introduced in the last century, why is someone still exploiting a bug-prone vulnerability, and it’s hard to maintain implicit joins β€” it's outside of me.

+1
source

All Articles