MySQL_WHERE clause & SELECT query (exercise)

Exercise 1: Query the employee information of department 90

#练习:查询90号部门的员工信息
SELECT * FROM employees
WHERE department_id = 90; #过滤条件

insert image description here


Exercise 2: Query the employee information of department 90

#练习:查询last_name为'King'的员工信息
SELECT * FROM employees
WHERE last_name = 'King'

insert image description here


Exercise 3: Query the total salary of employees for 12 months, and alias it as ANNUAL SALARY

SELECT employee_id,last_name,first_name,salary * 12 "ANNUAL SALARY" 
FROM employees

insert image description here


Exercise 4: Query the data after removing duplicate job_id in the employees table

SELECT DISTINCT job_id FROM employees

insert image description here


Exercise 5: Query the data after removing the duplicate job_id in the employees table

SELECT last_name,first_name,salary 
FROM employees
WHERE salary>12000

insert image description here


Exercise 6: Query the name and department number of the employee whose employee number is 176

SELECT last_name, department_id
FROM employees
WHERE employee_id = 176;

insert image description here


Exercise 7: Display the structure of the table departments and query all the data in it

DESC departments; #查询表结构(DESCRIBE或DESC)
SELECT * FROM departments; #查询全部数据

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/qq_45657848/article/details/127329186