What are the benefits of using LEFT OUTER JOIN instead of INNER JOIN in PHP when querying multiple tables?

When querying multiple tables in PHP, using a LEFT OUTER JOIN instead of an INNER JOIN allows you to retrieve all records from the left table, even if there are no matching records in the right table. This can be useful when you want to include all records from one table, regardless of whether there is a match in the other table.

$query = "SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.id = table2.table1_id";
$result = mysqli_query($connection, $query);

if(mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        // Process the retrieved data
    }
} else {
    echo "No results found.";
}