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 install Nginx in CentOS

Official documentation: https://nginx.org/en/linu...

mySQL server connection, disconnection and cmd operation

Use the mysql command to connect to the MySQL ser...

Nofollow makes the links in comments and messages really work

Comments and messages were originally a great way...

Introduction to network drivers for Linux devices

Wired network: Ethernet Wireless network: 4G, wif...

A solution to a bug in IE6 with jquery-multiselect

When using jquery-multiselect (a control that tra...

How to use React to implement image recognition app

Let me show you the effect picture first. Persona...

JavaScript object-oriented class inheritance case explanation

1. Object-oriented class inheritance In the above...

React tsx generates random verification code

React tsx generates a random verification code fo...

Quickly get started with VUE 3 teleport components and usage syntax

Table of contents 1. Introduction to teleport 1.1...