USE myemployees;#1.查询表中的单个字段SELECT last_name FROM employees;#2.查询表中的多个字段SELECT last_name,salary,email FROM employees;#3.查询表中的所有字段SELECT`employees_id`,`first_name`,`phone_number`FROM employees;SELECT*FROM employees
#4.查询常量值SELECT100;#5.查询表达式SELECT100%98;#6.查询函数SELECT VERSION();#7.起别名SELECT100%98AS 结果;SELECT last_name as 姓,first_name as 名 from employees;#8.查询salary ,显示结果为 out put SELECT salary AS"out put"FROM employees
#9.去重# 案列: 查询员工表中涉及到的所有部门编号SELECTDISTINCT department_id FROM employees
#10.# 案例:查询员工名和姓连接成一个字段,并显示为姓名SELECT CONCAT(str1,str2,...)AS 结果;SELECT CONCAT(last_name,first_name)AS 姓名 FROM employees;# 11.显示表departments的结构,并查询其中的全部数据DESC departments;SELECT*FROM`departments`;# 12.显示出表employees中的全部job_id (不能重复)SELECTDISTINCT job_id FROM employees;# 13.INNULL 如果为null 让它显示0SELECT IFNULL(commission_pct,0)AS 奖金率, commission_pct FROM employees;