黑猴子的家:mysql 查询练习测试

1、显示当前连接的所有数据库名称

SHOW DATABASES;
SELECT DATABASE();

2、查询employees表中的所有数据,并按年薪升序

SELECT * FROM employees
ORDER BY salary*12+(1+IFNULL(commission_pct,0)) ASC;

3、查询employee表中 ,部门编号在80到100之间的的last_name,employee_id 信息

SELECT last_name,employee_id
FROM employees WHERE department_id>=80 AND department_id<=100;

SELECT last_name,employee_id
FROM employees WHERE department_id BETWEEN 80 AND 100;

4、查询没有奖金,且工资小于18000的salary,last_name

SELECT salary,last_name 
FROM employees WHERE commission_pct IS NULL AND salary<18000;

5、查询employees表中,job_id不为 ‘IT’或者 工资为12000的员工信息

SELECT * FROM employees
WHERE job_id<>'IT' OR salary=12000;

你可能感兴趣的:(MySql)