Java Fundamentals (chapter IX)

Source: Internet
Author: User

Java Fundamentals (chapter IX)

I. Understanding the mechanism of the query

The client application (c/S, b/s) sends a SELECT statement to the DB of the backend server to query, returning the result set (virtual table) to the client application

Second, Select Statement

1. Querying all columns and rows in the table

SELECT * FROM table name

2. Query data according to conditions

SELECT * FROM table name where condition

3, query the data of some columns

Select Column Name 1, column Name 2 .... from table name [where condition]

4. Alias for column name

Way 1:select column name as alias from table name [where condition]

Method 2:select column name alias from table name [where condition]

Way 3:select alias = column name from table name [where condition]

5. Constant column

Select ' constant value ' as constant column name from table name [where condition]

6. Fetch the number of rows in the table

Method 1: Extract the fixed line

Select top row sequence name from table name [where condition]

Method 2: Extract data rows by percentage

Select top Percent Percent column name from table name [where condition]

7, query data, and sort

Ascending:

Select column Names list from table name [where Condition]torder by sort column name ' ASC '

Descending:

Select column list from table name [where condition]

Order by sort column name desc

8. Querying a table for a column with a null value in the data row

Select list List from table name where column name = ' or column name is null

Java Fundamentals (chapter IX)

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.