I am trying to use the results of a case statment as the ordering mechanism in my query. it errors saying no such column as ‘stuff’.
what is I doing wrong, please?
Please note that this sequencing requirement is a different one from that being done by sequence_number column.
select fd.file_name_other_language , fd.file_heading , fd.file_text , case when fd.text_or_a_list = 'text' then 1 else 0 end as stuff , fs.sequence_number , fi.image from file_data AS fd inner join file_sequencing AS fs on fs.file_id = fd.file_id left outer join file_images AS fi on fi.id = fd.id where fs.business_id = 504 and fs.file_name_in_home_language = 'Home' and fs.live_from = ( select max(b.live_from) from file_sequencing as b where b.business_id = fs.business_id and b.live_from <= curdate() and b.file_name_in_home_language = fs.file_name_in_home_language and fs.live_to = '0000-00-00' order by stuff asc