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

The functions and differences between disabled and readonly

1: readonly is to lock this control so that it can...

Solution to nginx not jumping to the upstream address

Preface Today I encountered a very strange proble...

MySQL 8.0.22 download, installation and configuration method graphic tutorial

Download and install MySQL 8.0.22 for your refere...

How to display div on object without being blocked by object animation

Today I made a menu button. When you move the mous...

Web front-end skills summary (personal practical experience)

1. Today, when I was making a page, I encountered ...

Detailed analysis of Vue child components and parent components

Table of contents 1. Parent components and child ...

Sample code for a simple seamless scrolling carousel implemented with native Js

There are many loopholes in the simple seamless s...

Use of CSS3's focus-within selector

Pseudo-elements and pseudo-classes Speaking of th...

Solution to the problem of English letters not wrapping in Firefox

The layout of text has some formatting requiremen...

Detailed explanation of vue keepAlive cache clearing problem case

Keepalive is often used for caching in Vue projec...

Some issues we should pay attention to when designing a web page

Web design, according to personal preferences and ...

Two methods to implement Mysql remote connection configuration

Two methods to implement Mysql remote connection ...

Differences between MySQL MyISAM and InnoDB

the difference: 1. InnoDB supports transactions, ...

Detailed explanation of basic operation commands for Linux network settings

Table of contents View network configuration View...