How to sort in MySQL:
Select * from table name [where condition order by field name ( default is asc in ascending order )]
ASC is in ascending order andDESC is used to specify descending order
Oracle Neutron query:
SELECT * from table name where condition (SELECT * from table name where condition)
Instance:
In:select * from EMP where deptno in (select Deptno from dept where loc = ' DALLAS ' or loc = ' bostom ');
All:select * from emp where sal > All (select Sal from emp where ename = ' JAMES ' or ename = ' FORD ');
Any:select * from emp where sal > No (select Sal from emp where ename = ' JAMES ' or ename = ' FORD ');
Exists:select * from EMP where exists (select Sal from emp where ename = ' JAMES ' or ename = ' FORD ');
The Union operation is used to calculate the unions of two result sets, which automatically remove duplicate rows of the result set when they are taken.
SELECT * from emp where SAL <=-union SELECT * from EMP where Sal >= 1500;
Intersect operation to calculate the intersection of two result sets
SELECT * from emp where Sal <=-intersect select * from EMP where Sal >= 1500;
The minus operation calculates the difference set of two result sets (only the data that exists in the first result set but does not exist in the second set)
SELECT * from emp where Sal <=-minus select * from emp where Sal >= 1500;
Other methods:
How MySQL is sorted