What are potential issues when accessing columns from different select queries using multiquery in PHP?

When accessing columns from different select queries using multiquery in PHP, one potential issue is that the result sets may not be easily distinguishable. To solve this, you can assign aliases to the columns in each query to make them unique and easily accessible in the PHP code.

<?php
// Establish a connection to the database
$mysqli = new mysqli("localhost", "username", "password", "database");

// Execute multiple queries
$multiQuery = "SELECT column1 AS query1_column1, column2 AS query1_column2 FROM table1; ";
$multiQuery .= "SELECT column3 AS query2_column1, column4 AS query2_column2 FROM table2;";
$mysqli->multi_query($multiQuery);

// Process the results
do {
    if ($result = $mysqli->store_result()) {
        while ($row = $result->fetch_assoc()) {
            // Access columns using aliases
            echo $row['query1_column1'] . ' ' . $row['query1_column2'] . "\n";
            echo $row['query2_column1'] . ' ' . $row['query2_column2'] . "\n";
        }
        $result->free();
    }
} while ($mysqli->next_result());

// Close the connection
$mysqli->close();
?>