Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to querying mysql database forms and using functions

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report