What potential pitfalls should be avoided when using ORDER BY in a MySQL query to filter results based on a specific condition?

When using ORDER BY in a MySQL query to filter results based on a specific condition, it's important to remember that the ORDER BY clause is applied after the WHERE clause. This means that if you want to filter results based on a specific condition, you should include that condition in the WHERE clause rather than relying on the ORDER BY clause to do the filtering. Failing to do so can result in incorrect or unexpected results.

// Incorrect usage of ORDER BY to filter results based on a condition
$query = "SELECT * FROM table_name WHERE column_name = 'value' ORDER BY column_name DESC";
```

```php
// Correct way to filter results based on a specific condition
$query = "SELECT * FROM table_name WHERE column_name = 'value' ORDER BY column_name DESC";