What are the potential pitfalls of using aliases in MySQL queries in PHP?

Using aliases in MySQL queries in PHP can lead to potential pitfalls such as confusion when referencing columns in the result set or when using the aliases in subsequent parts of the query. To avoid these issues, it is recommended to use the original column names instead of aliases in subsequent parts of the query.

// Example of using original column names instead of aliases in a MySQL query in PHP
$sql = "SELECT id AS user_id, name AS user_name FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "User ID: " . $row["id"] . " - User Name: " . $row["name"] . "<br>";
    }
} else {
    echo "0 results";
}