标签:
检索
1. select empno,ename,sal from emp;
2. select * from emp;
排序检索:
1. select * from emp order by sal;
2. select * from emp order by sal desc, hiredate; 工资降序,入社日期升序
3. select * from emp orber by 2,3; 按照第2,3行排序
过滤数据:
1. select * from emp where sal>500;
2. select * from emp where sal<>500;= select * from emp where sal!=500;
3. select * from emp where sal between 500 and 5000;
4. select * from emp where hiredate=‘2015-11-12‘ or hiredate=‘2003-10-09‘ and sal=1500;
应改成 select * from emp where (hiredate=‘2015-11-12‘ or hiredate=‘2003-10-09‘) and sal=1500;
否则and有优先权.
5. select * from emp where sal in (500,1500); = select * from emp where sal=500 or sal=1500;
6. select * from emp where not sal=2000;
通配符:
1. select * from emp where empno like ‘10%‘;
2. select * from emp where sal like ‘50%‘;
3. select * from emp where job like ‘%师%‘; %表示0个以上,包含0
4. select * from emp where job like ‘__师%‘; 两个_ 表示前面要有2个字, 有几个就要补充几个.
5. select * from emp where ename like ‘l%‘; l开头的
6. select CONCAT(ename,‘ (‘,job,‘)‘) as title from emp; 组成一个新的列
7. select ename,sal*12 as salary from emp where sal>500; ename, salary(别名)两个列
使用数据处理函数:
1.
标签:
原文地址:http://www.cnblogs.com/wujixing/p/5073893.html