What is the role of aliases in SQL statements and how can they be accessed in PHP?

Aliases in SQL statements are used to give a table or column a temporary name, making the SQL query more readable and concise. In PHP, you can access these aliases by fetching the results using the alias name specified in the SQL query.

// Example SQL query with aliases
$sql = "SELECT first_name AS fname, last_name AS lname FROM users";
$result = mysqli_query($conn, $sql);

// Accessing aliases in PHP
while($row = mysqli_fetch_assoc($result)) {
    echo $row['fname'] . " " . $row['lname'] . "<br>";
}