当前位置:网站首页>MySQL - database query - basic query
MySQL - database query - basic query
2022-07-03 01:20:00 【Sauerkraut】
The basic query
MySQL Database usage SELECT Statement to query data .
1. Query multiple fields
The following is in MySQL A common way to query data in a database SELECT grammar :
SELECT Field name , Field name ... FROM Table name ;
SELECT * FROM Table name ; # Query all fields
You can use one or more tables in a query statement , Use commas between tables (,) Division , And use WHERE Statement to set the query conditions .
SELECT Command can read one or more records .
You can use an asterisk (*) To replace other fields ,SELECT Statement will return all the field data of the table
2. Set alias
SELECT Field 1 [AS Alias ], Field 2 [AS Alias ]... FROM Table name ;
3. Remove duplicate records
SELECT DISTINCT Field list FROM Table name ;
4. Four arithmetic queries
Query requirement
Check the file code
How to get there Navicat Import inside sql Data? ?
Start query operation
1. Query the specified field ename,job,sal The data of
SELECT ename,job,sal FROM emp;
2. Query all fields
SELECT empno,ename,job,mgr,hiredate,comm,deptno FROM emp;
Or use the following method to query all fields
① Not intuitive enough , You can't tell which fields there are at a glance
② Affect the efficiency of execution , First, go to the table to find which fields , And then check it out , There is one more step to find
-- Direct use is not recommended * --
SELECT * FROM emp;
3. Query all positions of employees , And name it
SELECT ename,job FROM emp;
names
SELECT ename,job AS ' jobs ' FROM emp;
AS It can be omitted
SELECT ename,job ' jobs ' FROM emp;
4. Query the positions of employees ( Don't repeat )
SELECT job FROM emp;
Pay attention to the repetition , You need to display only one repetition
Use DISTINCT Keyword de duplication
SELECT DISTINCT job FROM emp;
If there are multiple fields , Can't get rid of the duplicate , This is the de duplication of a single field
5. Check the annual salary of employees namely sal * 12
SELECT ename,sal AS ' a monthly salary ',sal * 12 AS ' Annual salary ' FROM emp;
SELECT sal / 10 FROM emp;
SELECT sal DIV 10 FROM emp;
边栏推荐
- Androd Gradle 对其使用模块依赖的替换
- How wide does the dual inline for bread board need?
- 用Go+绘制爱心给心爱的她表白
- 2022 cable crane driver examination registration and cable crane driver certificate examination
- 【FH-GFSK】FH-GFSK信号分析与盲解调研究
- The R language uses the ctree function in the party package to build conditional inference decision trees, uses the plot function to visualize the trained conditional inference decision tree, and the
- 对非ts/js文件模块进行类型扩充
- 正确甄别API、REST API、RESTful API和Web Service之间的异同
- 产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
- Explain the basic concepts and five attributes of RDD in detail
猜你喜欢
leetcode 6103 — 从树中删除边的最小分数
基本远程连接工具Xshell
MySQL
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
Leetcode 2097 - Legal rearrangement of pairs
MySQL --- 数据库查询 - 条件查询
Basis of information entropy
Detailed explanation of Q-learning examples of reinforcement learning
Merge K sorted linked lists
【FH-GFSK】FH-GFSK信号分析与盲解调研究
随机推荐
LDC Build Shared Library
Linear programming of mathematical modeling (including Matlab code)
Canvas drawing -- bingdd
按键精灵打怪学习-自动寻路回打怪点
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
Trois tâches principales: asynchrone, courrier et timing
[Arduino experiment 17 L298N motor drive module]
Matlab Doppler effect produces vibration signal and processing
Androd Gradle 对其使用模块依赖的替换
Basis of information entropy
关于Fibonacci数列
Basic use of sringcloud & use of component Nacos
【FPGA教程案例5】基于vivado核的ROM设计与实现
MySQL foundation 06 DDL
[untitled]
Several cases of recursive processing organization
Key wizard play strange learning - multithreaded background coordinate recognition
Arduino dy-sv17f automatic voice broadcast
excel去除小数点后面的数据,将数字取整
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet