Lessonaim
While retrieving data from the database, you may need to restrict the rows of data that is displayed or specify The order in which the rows is displayed.
This lesson explains the SQL statements, Youuse to perform these actions.
? filter rows in the query.
? sort the rows in the query.
SELECT *| {[DISTINCT] column|expression [alias],...}
from Table
[WHERE condition (s)];
?WHEREclause follows fromclauses。
Select employee_id , last_name , job_id , department_id
From Employees
WHERE department_id = +;
?characters and dates to be included in thesingle quotation marksin。?character case sensitive, date format sensitive。
SELECT last_name , job_id , department_id
From Employees
WHERE last_name = ' Whalen ';
SELECT last_name , hire_date , department_id
From Employees
WHERE hire_date = ' 7-6 Month -1994 '
The date is written in a specific format!
SELECT last_name , Salary
From Employees
WHERE Salary <= 3000;
1.
SELECT last_name , Salary
From Employees
WHERE salary between 2500 and 3500;
2.
SELECT employee_id , last_name , salary, manager_id
From Employees
WHERE manager_id In (101, 201);
? Use the like operation to select a similar value? The selection criteria can contain characters or numbers: –% represents 0 or more characters(any of the characters)。_represents a character
3.
SELECT first_name
From Employees
WHERE first_name Like ' s% ';
4.
SELECT last_name
From Employees
WHERE last_name Like ' _o% ';
? You can useESCAPEIdentifiers select '% ' and ' _ ' symbols.
? avoidance of special symbols:using escape characters。 For example: convert [%] to [\%], [_] to [\_], and then add [ESCAPE '].
SELECT job_id
from Job s
WHERE job_id Like ' it\_ % ' escape ' \ ' ;
5.
Null value is determined using is (not)null .
SELECT last_name , manager_id
From Employees
WHERE manager_id is NULL;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Oracle section 2nd filters and sorts data