Why is it advised against using SELECT * in a SQL query for production code?

Using SELECT * in a SQL query for production code is advised against because it can return more data than necessary, leading to increased network traffic and decreased performance. It also makes the code less maintainable as any changes to the table structure can affect the query results. It is better to explicitly list the columns needed in the SELECT statement to improve performance and maintainability.

// Instead of using SELECT * in a SQL query, explicitly list the columns needed
$query = "SELECT column1, column2, column3 FROM table_name";
$result = mysqli_query($connection, $query);

// Process the query result as needed