How can aliases be effectively used in PHP SELECT statements when dealing with JOIN operations?

When dealing with JOIN operations in PHP SELECT statements, aliases can be effectively used to simplify the query and make it more readable. By assigning aliases to tables and columns, you can refer to them using shorter names throughout the query. This can help avoid naming conflicts and make the query easier to understand.

$query = "SELECT t1.column1 AS alias1, t2.column2 AS alias2
          FROM table1 AS t1
          JOIN table2 AS t2 ON t1.id = t2.id";
$result = mysqli_query($conn, $query);

if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo $row['alias1'] . " - " . $row['alias2'] . "<br>";
    }
}