标签:
一、检索数据:
1.查找满足多个条件的行:
SELECT
*
FROM
emp
WHERE
DEPTNO = 10
OR comm IS NOT NULL
OR sal <= 2000
AND DEPTNO = 20;
其返回部门10中所有员工+所有得到提成的员工+部门20中工资不超过2000美金的员工。
SELECT
*
FROM
emp
WHERE
(
deptno = 10
OR comm IS NOT NULL
OR sal <= 2000
)
AND DEPTNO = 20;
其仅仅返回部门20中符合条件的员工
2.在where子句中引用取别名的列:
SELECT
*
FROM
(
SELECT
sal AS salary,
comm AS commision
FROM
emp
) x
WHERE
salary < 5000;
3.连接列值:
SELECT
ename || ‘ WORKS AS A ‘ || JOB
FROM
emp
WHERE
deptno = 10;
4.
标签:
原文地址:http://www.cnblogs.com/xavierjzhang/p/4501598.html