MySQL OUTER JOIN syntax error
MySQL OUTER JOIN syntax error
579
27-Jul-2023
Aryan Kumar
28-Jul-2023MySQL does not support the
OUTER JOINkeyword. Instead, you can use theLEFT JOIN,RIGHT JOIN, orFULL JOINkeywords to achieve the same results.The
LEFT JOINkeyword returns all rows from the left table, even if there are no matching rows in the right table. TheRIGHT JOINkeyword returns all rows from the right table, even if there are no matching rows in the left table. TheFULL JOINkeyword returns all rows from both tables, even if there are no matching rows in the other table.For example, the following SQL statement will use a
LEFT JOINto return all products, even if they do not have a corresponding category:SQL
This will return all rows from the
productstable, even if there are no matching rows in thecategoriestable. Thecategoriestable will only be included in the results if there is a matching row in theproductstable.Here is an example of how to use the
LEFT JOINkeyword in MySQL:SQL
This will return the following result:
As you can see, the
LEFT JOINkeyword has returned all rows from theproductstable, even if they do not have a corresponding category. Thecategoriestable will only be included in the results if there is a matching row in theproductstable.