MySQL query learning basic query operations

MySQL query learning basic query operations

Preface

MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software.

MySQL is a relational database management system developed by the Swedish company MySQL AB and currently owned by Oracle. MySQL is a relational database management system that stores data in different tables instead of putting all data in one large warehouse, which increases speed and flexibility.
This article mainly explains the basic queries for querying data in the MySQL database.

Query data

In the MySQL database, the select statement is used to query data. The syntax is:

SELECT query list FROM table name;

Using select query has the following characteristics:

  1. The result set of the query is a virtual table
  2. The result of the select query is more similar to the statement System.out.println (content to be printed) in Java. The printed table cannot be directly operated and can only provide data display.
  3. The query sequence of this statement is:
    First check whether the table name after FROM exists. If it does not exist, an error is returned and no subsequent queries are performed. Then check whether the table contains the contents of the query list after the SELECT clause.
  4. The content of the "query list" can include not only fields, but also functions, expressions, constants, etc.
    Note: The content in the "query list" can be composed of multiple parts, separated by commas, and "*" can represent all the information in the query table

For example:

SELECT
	name,age,class,id
FROM
	classroom;

Example:

①Query constants

SELECT 100;

Query results:


②Query expression

SELECT 100+6;

Query results:


③Query fields

Query a single field

SELECT last_name FROM employees;

Query results:

Query multiple fields

SELECT salary,last_name,first_name FROM employees;

Query results:

Query all fields

SELECT * FROM employees;

Query results:


④Query function

Commonly used query functions are:

SELECT DATABASE();#Query the currently called databaseSELECT VERSION();#Query the database versionSELECT USER();#Query the current user

Summarize

The basic query statements in the MySQL database are the most commonly used and basic statements when using the database. Proficiency in this part of the content also lays the foundation for learning other content of the MySQL database.

You may also be interested in:
  • PHP basics: connecting to MySQL database and querying data
  • Basic learning tutorial of table subquery and correlated subquery in MySQL
  • MySQL infrastructure tutorial: detailed explanation of the query statement execution process

<<:  Usage scenarios and source code analysis of Vue advanced components functional components

>>:  On good design

Recommend

How to set the number of mysql connections (Too many connections)

During the use of mysql, it was found that the nu...

MySQL learning notes: data engine

View the engines supported by the current databas...

Solve the problem of OpenLayers 3 loading vector map source

1. Vector Map Vector graphics use straight lines ...

How to use Typescript to encapsulate local storage

Table of contents Preface Local storage usage sce...

Three Discussions on Iframe Adaptive Height Code

When building a B/S system interface, you often en...

How are spaces represented in HTML (what do they mean)?

In web development, you often encounter characters...

How to configure common software on Linux

When you get a new Linux server, you generally ha...

Summary of 50+ Utility Functions in JavaScript

JavaScript can do a lot of great things. This art...

Centos8 builds nfs based on kdc encryption

Table of contents Configuration nfs server (nfs.s...

Basic usage and pitfalls of JavaScript array sort() method

Preface In daily code development, there are many...

Tutorial on installing MySQL8 compressed package version on Win10

1 Download MySQL8 from the official website and i...

Add a startup method to Linux (service/script)

Configuration file that needs to be loaded when t...