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)