Introduction to querying mysql database forms and using functions
The following mainly brings you query mysql database forms and use functions, I hope these contents can bring you practical use, which is also the main purpose of my editing query mysql database forms and use functions this article. Okay, no more nonsense, let's go straight to the following.
Single table query
Prepare an employee list company.employee
Employee number emp_id int
Employee name emp_name varchar(30)
Employee sex enum
hire date hire_date
post varchar(50)
Job description job_description varchar(50)
salary double(15,2)
Office int
dep_id int
A simple query of the table
Select * from employee; //View all
Select Field 1, Field 2,... field n from table name
Avoid repeating the keyword distinct
Select distinct post from employee
Relational operators: + - *, %
Select emp_name salary*12 from employee;
As alias
Select emp_name as name salary*12 as salary from employee;
define display format concat() function for concatenating strings
Select concat (emp_name,'annual salary', salary*12) as Employee Annual Salary
From employee;
II. Query by condition
conditional query conditional expression
Comparison operator: > = 100000;
Keyword query between and
Select emp_name from employee
Where salary between 5000 and 15000; //Salary between 5000 and 15000
Select emp_name from employee
Where salary is not between 5000 and 15000; //Person whose salary is not between 5000 and 15000
Keyword query is null
Select emp_name,job_description from employee
Where job_description is null; //View employees whose job description is null
Select emp_name,job_description from employee
Where job_description is not null; //View non-null employee job description
For the above query mysql database forms and use functions, we do not think very helpful. If you need to know more, please continue to pay attention to our industry information, I believe you will like these contents.