微前端架构如何改变企业的开发模式与效率提升
651
2022-08-31
mysql数据库中select 基本查询(1)
SELECT 1+'a'
FROM DUAL;
SELECT * FROM employees;
#mysql 基本运算
SELECT 1+1,3*2
FROM DUAL; #伪表
SELECT * FROM employees;
#查询员工的id,名字,薪资
SELECT employee_id,last_name,salary
FROM employees
#查询出有多少个部门,且不重复
SELECT DISTINCT department_id
FROM employees;
SELECT salary,DISTINCT department_id
FROM employees;
SELECT DISTINCT salary, department_id
FROM employees;
#只要有null 的值参与运算的结果是null,所以查询出来的结果不准确
SELECT employee_id,salary "月工资",salary * (1 + commission_pct) * 12 "年工资",commission_pct
FROM employees
#改进方法 IFNULL(commission_pct,0) ,如果commission的值为null 则置为0
SELECT employee_id,salary "月工资",salary * (1 + IFNULL(commission_pct,0)) * 12 "年工资",commission_pct
FROM employees
# select * from order 错误的,因为order 是关键字 所以要用着重号
SELECT *FROM `order`;
#查询90号部门员工的信息
DESC employees;
SELECT * FROM employees
WHERE department_id=90;
# 查询lastname 为king 的员工信息
SELECT employee_id,last_name,department_id
FROM employees
WHERE last_name='king';
#因为此处的sql语句 执行过程是 先执行from 子句,然后执行where 子句,最后执行select子句,
#所以会报Unknown column 'did' in 'where clause'
SELECT employee_id emid,last_name "姓名",department_id AS did
FROM employees
WHERE did=90;
SELECT employee_id emid,last_name "姓名",department_id AS 部门ID
FROM employees
WHERE department_id=90;
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~