Mysql基础
起别名的方式:
1. *第一种*
SELECT department_id AS id FROM departments;
2. 第二种:省略掉AS用空格替换
SELECT department_id id FROM departments;
3. 以特殊符号作为别名的要加引号(单双都可)
SELECT department_id '#' FROM departments;
去重(distinct)
将该列种所有的重复的数据去除
SELECT DISTINCT department_id FROM departments;
字符串拼接(concat函数) 弊端:bull和任何字符串拼接都为null 解决方法:(ifnull函数`)
Ifnull(列,返回值):如果为空,就会替换成返回值
列于列以字符串隔开,commission_pct列为空返回值0,拼接
select
concat(first_name,",",last_name,",",job_id,",",ifnull(commission_pct,0))as 拼接 from employees;
显示表的数据结构:显示数据表结构:desc +tablename
|