Detailed graphic explanation of mysql query control statements

Detailed graphic explanation of mysql query control statements

mysql query control statements

Field deduplication

**Keyword: distinct**
Syntax: select distinct field name from table name;

Case: Deduplication of departments

Select distinct dep from emp; 

ifnull syntax

Null plus any number equals null

Use ifnull to replace null values

Syntax: Select ifnull (field name that may be empty, if empty, replace it with something) from table name;

Example: View the sum of an employee's monthly salary and commission

Select sal+ifnull(comm,0) from emp;


Aliasing fields

Method: select field name as alias from table name

Select field name alias from table name

Sorting:

		Keywords: order by
		Syntax: Select field name from table name order by field name (used for sorting) asc (ascending)/desc (descending)

Aggregate functions:

MySQL provides aggregate functions for calculating fields.
Sum(): sums a whole column of data
Count(): count the number of nulls and do not count
Max(): Maximum value
Min(): minimum value
Avg(): average value
Round(): round the decimal places (..., how many places)

Example: Total salary

Summarize

This is the end of this article about MySQL query control statements. For more relevant MySQL query control statements, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • An article to understand the execution process of MySQL query statements
  • Detailed explanation of the execution process of MySQL query statements
  • Detailed explanation of the idea of ​​using Python sql statements to perform multi-condition fuzzy queries on mysql database
  • Example code for converting Mysql query result set into JSON data
  • Use Visual Studio Code to connect to the MySql database and query
  • MySQL query optimization: causes and solutions for slow queries
  • Optimizing the slow query of MySQL aggregate statistics data
  • Specific example of MySQL multi-table query
  • A complete example of mysql querying batch data from one table and inserting it into another table
  • Analyze how a SQL query statement is executed in MySQL

<<:  JS array deduplication details

>>:  Modify the default scroll bar style in the front-end project (summary)

Recommend

32 Typical Column/Grid-Based Websites

If you’re looking for inspiration for columnar web...

js to realize payment countdown and return to the home page

Payment countdown to return to the home page case...

Detailed explanation of Vue plugin

Summarize This article ends here. I hope it can b...

Design theory: people-oriented design concept

<br />When thoughts were divided into East a...

Summary of CSS front-end knowledge points (must read)

1. The concept of css: (Cascading Style Sheet) Ad...

HTML tbody usage

Structured Table (IExplore Only) 1) Group by rows ...

Introduction to using data URI scheme to embed images in web pages

The data URI scheme allows us to include data in a...

Vue implements a simple shopping cart example

This article example shares the specific code of ...

MySQL Innodb key features insert buffer

Table of contents What is insert buffer? What are...

JavaScript to implement the web version of the snake game

This article shares the specific code for JavaScr...

Detailed explanation of Vue component reuse and expansion

Table of contents Overview Is the extension neces...

Four modes of Oracle opening and closing

>1 Start the database In the cmd command windo...