Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL is this equivalent to a LEFT JoIn?

Is this equivalent to a LEFT JOIN?

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

It seems as though there is no link between the two tables.

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

like image 703
Jim Avatar asked Aug 18 '26 07:08

Jim


2 Answers

Not, it is equivalent to a cross or cartesian join (really bad) with a distinct applied afterwards. It is pretty hard to know what you really want with the query as it stands.

like image 191
Otávio Décio Avatar answered Aug 19 '26 21:08

Otávio Décio


Isn't this the same as

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

although I would be questioning the purpose for this query.

like image 33
Doug Stalter Avatar answered Aug 19 '26 21:08

Doug Stalter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!