Skip to content

Order By Clause

An ORDER BY clause requires the order field to be part of the SELECT statement

Correct
SELECT 
    `Address.City` AS City, ABS(`id`) AS absId 
FROM 
    `customers` 
WHERE 
    `First Name` LIKE 'm%' AND ABS(`id`) > 1 
ORDER BY absId
Incorrect
SELECT 
    `Address.City` AS City 
FROM 
    `customers` 
WHERE 
    `First Name` LIKE 'm%' AND ABS(`id`) > 1 
ORDER BY ABS(`id`)