#查询公司中的员工的姓名 以及入职时间 SELECT CONCAT(`last_name`, ' ', `first_name`) AS 姓名, `hiredate` 入职时间 FROM `employees` ; #查询员工表中涉及到得所有的部门编号 SELECT DISTINCT `department_id` FROM `employees` ; USE myemployees; #1,查询表中的单个字段 SELECT last_name FROM employees; #2,查询表中的多个字段 SELECT last_name,salary,email FROM employees; #3,查询表中的所有字段 #方式一: SELECT first_name, last_name, email, phone_number, job_id, salary, commission_pct, manager_id, department_id, hiredate FROM employees ; #方法二: SELECT * FROM `employees`; #4,查询常量值 SELECT 100; SELECT 'john'; SELECT 5*5-5; #5,查询表达式 SELECT 100%90; SELECT 500%77 #6,查询函数 SELECT MAX(salary) FROM `employees`; #7,起别名 /* 便于理解 如果要查询的字段有重名的情况,使用别名可以区分开来 */ #方式一:使用as SELECT 1000%666 AS 余数结果; SELECT last_name AS 姓,first_name AS 名 FROM employees; #方法二:使用空格 SELECT last_name 姓,first_name 名 FROM employees; #案例:查询salary,显示结果为 out put SELECT salary AS "out put" FROM employees; #8,去重 #案例:查询员工表中涉及到得所有的部门编号 使用distinct SELECT DISTINCT `department_id` FROM employees; SELECT DISTINCT `manager_id` FROM `departments`;