Turing programming series (SQL must know) notes

Source: Internet
Author: User

SQL must know

Lesson two: Retrieving data

  1. Paging

(1), SQL Server chestnuts: Select top 2 columns from TableName

(2), Oracle chestnut: SELECT * from TableName ROWNUM <= 5

(3), Mysql chestnut: selct * from TableName limit 5

Precautions:

1, MySQL paging if you want to query No. 0 start Query 10 Chestnut select * FROM tableName limit offset 0 Simplified version is commonly used limit 0,10 where "0" represents the offset "10" represents the L Imit

Lesson two: Sorting the retrieved data

1, multi-column sorting

SELECT * from TableName ORDER by Column1,column2

Description: (1), if Column1 is unique, does not sort column2.

(2), if it is not unique, the column2 is sorted on a non-unique (column1 basis of the same value).

Keep updating ....

   

Turing programming series (SQL must know) notes

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.