How MySQL is sorted

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.