SQL is equivalent to LEFT JoIn?

Is this the equivalent of a LEFT JOIN?

SELECT DISTINCT a.name, b.name 
  FROM tableA a, 
       (SELECT DISTINCT name FROM tableB) as b

There seems to be no relationship between the two tables.

Is there an easier / more efficient way to write this?

+3
source share
5 answers

No, this is equivalent to a cross or Cartesian compound (very bad) with a clear application after that. It is very difficult to understand what you really want with the request because it is worth it.

+4
source

Isn't it like that

SELECT DISTINCT a.name, b.name
    FROM tableA a, tableB b

although I would question the purpose of this request.

+2
source

ANSI-89 , ( ). ANSI-92 JOIN:

SQL Server/Oracle/Postgres, :

    SELECT DISTINCT
           a.name,
           b.name
      FROM TABLEA a
CROSS JOIN (SELECT b.name 
              FROM TABLEB b) AS b

MySQL :

SELECT DISTINCT
       a.name,
       b.name
  FROM TABLEA a
  JOIN (SELECT b.name 
          FROM TABLEB b) AS b

, - , , INNER JOIN OUTER JOIN.

+2

, . . , . , .

.. . (

</a >

+2

, -. , , , , .

. , . ( , , ). , . , , , : a 467 b 4413 2060871 826804 4712 893

Thus, you can see that adding a separate to the cross join reduces the number of records returned, but does not guarantee that you will get the result that you would have with the correct join. Given that you said the tables were the address of the company and the company, it would be very unlikely that the cross-connection was what you wanted.

+1
source

Source: https://habr.com/ru/post/1735994/


All Articles