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

Sample code on how to implement page caching in vue mobile project

background On mobile devices, caching between pag...

Why do select @@session.tx_read_only appear in DB in large quantities?

Find the problem When retrieving the top SQL stat...

CentOS 8 officially released based on Red Hat Enterprise Linux 8

The CentOS Project, a 100% compatible rebuild of ...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Vue uses element-ui to implement menu navigation

This article shares the specific code of Vue usin...

Tutorial on resetting the root password of Mac MySQL

Disclaimer: This password reset method can direct...

30 excellent examples of color matching in web design

Today, this article has collected 30 excellent cas...

Linux system AutoFs automatic mount service installation and configuration

Table of contents Preface 1. Install the service ...

Designing the experience: What’s on the button

<br />Recently, UCDChina wrote a series of a...

Linux/Mac MySQL forgotten password command line method to change the password

All prerequisites require root permissions 1. End...

A brief description of the relationship between k8s and Docker

Recently, the project uses kubernetes (hereinafte...

js to implement a simple bullet screen system

This article shares the specific code of native j...

Use Xshell to connect to the Linux virtual machine on VMware (graphic steps)

Preface: I recently started to study the construc...

MySQL concurrency control principle knowledge points

Mysql is a mainstream open source relational data...

Detailed explanation based on event bubbling, event capture and event delegation

Event bubbling, event capturing, and event delega...