单表查询语法

select distinct 字段1,字段2,字段3.。from表名

where约束条件

group by 分组的字段

having 过滤条件

order by 排序字段

limit 限制条件

 

简单查询

SELECT id,name,sex,age,hire—date,post—comment,salary,office

depart—id FROM employee;

 

SELECT*FROM employye;

SELECT name,salary FROM employee;

避免重复DISTINCT

SELECT DISTINCT post FROM employye;

通过四则运算查询

SELECT name,salary*12 FROM employee;

SELECT name,salary*12 AS Annual—salary FROM employee;

SELECT name, salary*12 Annual_salary FROM empoyee;

定义显示格式

CONCAT()函数用于连接字符串

SELECT CONCAT(‘姓名:’‘name,’‘年薪:’,salary*12)AS Annual_salary

FROM employee;

CONCAT_WS()第一个参数为分隔符

SELECT CONCAT_WS(':',neme,salary*12)AS Annual_salary

FROM employee;

posted @ 2017-10-25 19:58  程绩  阅读(318)  评论(0编辑  收藏  举报