SELECT
IF(image_location_country IS NULL OR image_location_country = '', 'x', NULL) AS image_location_country_alt,
image_path
FROM image
WHERE image_path REGEXP '\/www\/html\/tools\/images\/myalbum/.+$'
ORDER BY upper(image_location_country_alt) desc,
upper(image_location_country) DESC,
upper(image_location_state) DESC,
upper(image_location_city) DESC,
upper(image_name) DESC,
upper(right(image_name, 2)) DESC
LIMIT 1
This query produces the following error:
Unknown column 'image_location_country_alt' in 'order clause' using query
I'm sorry but I must have this "column" in the query, it's vital for required sorting order (you have to sort image_location_country in alphanumeric order, however, that column can also be null, BUT all NON-NULL fields MUST BE FIRST before all NULL fields!)
I'm not sure what's happening, please help!
Thanx
Phil