当前位置:网站首页>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;

边栏推荐
- Key wizard play strange learning - front desk and Intranet send background verification code
- excel表格计算时间日期的差值,并转化为分钟数
- Telephone network problems
- leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】
- dotConnect for PostgreSQL数据提供程序
- matlab查找某一行或者某一列在矩阵中的位置
- LDC Build Shared Library
- 【FPGA教程案例5】基于vivado核的ROM设计与实现
- ThinkPHP+Redis实现简单抽奖
- leetcode 2097 — 合法重新排列数对
猜你喜欢
![[Androd] Gradle 使用技巧之模块依赖替换](/img/5f/968db696932f155a8c4a45f67135ac.png)
[Androd] Gradle 使用技巧之模块依赖替换

Matlab saves the digital matrix as geospatial data, and the display subscript index must be of positive integer type or logical type. Solve the problem

leetcode 2097 — 合法重新排列数对

leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】
![[fh-gfsk] fh-gfsk signal analysis and blind demodulation research](/img/8a/8ca80f51a03341c982d52980c54b01.png)
[fh-gfsk] fh-gfsk signal analysis and blind demodulation research

Database SQL language 02 connection query
![[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)](/img/f5/3ec22f1480227f33a1c8ac457155ed.jpg)
[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)
![leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]](/img/2c/8ec3926243fac8db9ed45d8053f3af.png)
leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]

Niu Ke swipes questions and clocks in

12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
随机推荐
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
[shutter] image component (configure local GIF image resources | load placeholder with local resources)
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
Excel removes the data after the decimal point and rounds the number
MySQL
kivy教程之在 Kivy App 中使用 matplotlib 的示例
链表中的节点每k个一组翻转
leetcode 6103 — 从树中删除边的最小分数
寻找标杆战友 | 百万级实时数据平台,终身免费使用
Assets, vulnerabilities, threats and events of the four elements of safe operation
R language ggplot2 visual faceting, visual facet_wrap bar plot, using strip Text function customize the size of the strip of each facet title in the facet graph (cutimi
excel表格计算时间日期的差值,并转化为分钟数
MySQL --- 数据库查询 - 基本查询
Kivy教程大全之如何在 Kivy 中创建下拉列表
看疫情之下服装企业如何顺势而为
Mongodb common commands of mongodb series
MySQL basic usage 02
Foundations of data science is free to download
Correctly distinguish the similarities and differences among API, rest API, restful API and web service