0

I don't understand, why the following query produced an error. Whereas in other dbms (eg mysql) this sort of query is absolutely legal.

ERROR: Syntax error at the end of input
LINE 1: SELECT * FROM "addr_country" AS c JOIN "addr_state" AS s
                                                                ^

SQL state: 42601
Character: 59

Adding an on-clause to the query makes it working:

SELECT * FROM "addr_country" AS c JOIN "addr_state" AS s
ON c."id" = s."country" AND s.id = 10
emfi
  • 649
  • 6
  • 23
  • 2
    A `JOIN` needs a join condition. The first query is absolutely not legal. If that works in "other" DBMS that DBMS blatantly ignores even the most basic SQL syntax rules. The only join that does not need a join condition would be a `CROSS JOIN` –  Mar 19 '19 at 10:37
  • Oh, due to this answer: https://stackoverflow.com/a/16471286/1961222, `MySQL` makes a `cross join` on that syntax. – emfi Mar 19 '19 at 10:56
  • 1
    I guessed it was MySQL's stupid behaviour to avoid error messages at all costs even if that means they are returning the wrong results. –  Mar 19 '19 at 10:59

1 Answers1

0

Due to this answer, MySQL makes a cross join out of a join w/o conditions

emfi
  • 649
  • 6
  • 23