UNION ALL Operator with ORDER BY Command in MYSQL

In this tutorial, I will show you how to use ORDER BY command with UNION ALL Operator.
This is common for MYSQL and Oracle.  

Let's assume following is your table named "FILM"




Step 1: Write the following SQL statement


select * from film
where rating= 'NC-17'
UNION ALL
select * from film
where title = 'NOON PAPI'
UNION ALL
select * from film
where title = 'AFRICAN EGG'
order by 7



In here ORDER BY 7 - 7 means the 7th column from the right-hand side.

Comments