0

Why would you use the CROSS JOIN keyword if you can just do INNER JOIN and have no condition? Am I missing something? Also can cross joins have on conditions?

joshua.vw
  • 67
  • 3
  • 3
    Have you researched this online before posting the question? I am sure there are tons of explanation. So to answer your question, they're definitely not the same. – Eric Mar 02 '20 at 17:41
  • 1
    @Eric *they're definitely not the same* That's true... but not for MySQL. – Akina Mar 02 '20 at 18:11
  • In MySQL, the CROSS keyword is ignored, but it still might be included, either for portability or for clarity (human comprehension) – Strawberry Mar 02 '20 at 19:47
  • This is a faq. Before considering posting please always google any error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags; read many answers. If you post a question, use one phrasing as title. See [ask] & the voting arrow mouseover texts. – philipxy Mar 02 '20 at 20:42
  • "Why" is not a clear question. It's never clear what a valid answer is. "Why" have CROSS JOIN in standard SQL when it means INNER JOIN ON 1=1? Because a bunch of things were balanced & a decision was made. Ask "what". After you research. Ask 1 clear specific non-duplicate question per post. – philipxy Mar 02 '20 at 20:46
  • Does this answer your question? [Is CROSS JOIN a synonym for INNER JOIN without ON clause?](https://stackoverflow.com/questions/5742196/is-cross-join-a-synonym-for-inner-join-without-on-clause) – philipxy Mar 02 '20 at 21:40

1 Answers1

1

In MySQL, JOIN, CROSS JOIN, and INNER JOIN are syntactic equivalents (they can replace each other).

In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise.

MySQL Reference Manual / ... / JOIN Clause

Community
  • 1
  • 1
Akina
  • 39,301
  • 5
  • 14
  • 25