LessonAim
While retrieving data from the database, you may need to restrict the rows of data that are displayed or specify the order in which the rows are displayed.
This lesson explains the SQL statements that youuse to perform these actions.
SELECT *|{[DISTINCT] column|expression [alias],...}
FROM table
[WHERE condition(s)];
SELECT employee_id,last_name,job_id,department_id
FROM employees
WHERE department_id = 90 ;
SELECTlast_name,job_id,department_id
FROM employees
WHERE last_name = ‘Whalen‘;
SELECTlast_name,hire_date,department_id
FROM employees
WHERE hire_date =‘7-6月-1994‘
日期以特定的格式书写!
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 (100, 101, 201);
3.
SELECT first_name
FROM employees
WHERE first_name LIKE ‘S%‘;
4.
SELECT last_name
FROM employees
WHERE last_name LIKE ‘_o%‘;
SELECT job_id
FROM jobs
WHERE job_id LIKE ‘IT\_%‘ escape ‘\‘;
5.
使用IS (NOT)NULL 判断空值。
SELECT last_name,manager_id
FROM employees
WHERE manager_id IS NULL;
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/u014338577/article/details/47113547