In the provided code snippet, what potential issues can arise from the incorrect placement of the "ORDER BY" clause in the SQL query?
Placing the "ORDER BY" clause in the incorrect position in the SQL query can result in syntax errors or unexpected results. To solve this issue, the "ORDER BY" clause should always be placed at the end of the query, after the "WHERE" and "GROUP BY" clauses (if present). This ensures that the ordering is applied correctly to the filtered and grouped data.
// Incorrect placement of ORDER BY clause
$query = "SELECT * FROM users ORDER BY name DESC WHERE status = 'active'";
// Correct placement of ORDER BY clause
$query = "SELECT * FROM users WHERE status = 'active' ORDER BY name DESC";