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

边栏推荐
- 不登陆或者登录解决oracle数据库账号被锁定。
- 如今少年已归来,人间烟火气最抚凡人心 复工了~
- [fh-gfsk] fh-gfsk signal analysis and blind demodulation research
- Correctly distinguish the similarities and differences among API, rest API, restful API and web service
- Look at how clothing enterprises take advantage of the epidemic
- Daily topic: movement of haystack
- 2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
- 鏈錶內指定區間反轉
- (C language) data storage
- 删除有序链表中重复的元素-II
猜你喜欢

Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man

寻找标杆战友 | 百万级实时数据平台,终身免费使用

RISA rz/g2l processor introduction | frame diagram | power consumption | schematic diagram and hardware design guide
![[Androd] Gradle 使用技巧之模块依赖替换](/img/5f/968db696932f155a8c4a45f67135ac.png)
[Androd] Gradle 使用技巧之模块依赖替换

leetcode 2097 — 合法重新排列数对

Database SQL language 01 where condition

What is needed to develop a domestic arm intelligent edge computing gateway

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

正确甄别API、REST API、RESTful API和Web Service之间的异同

First hand evaluation of Reza electronics rz/g2l development board
随机推荐
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
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
Correctly distinguish the similarities and differences among API, rest API, restful API and web service
MySQL基础用法02
合并K个已排序的链表
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
按键精灵打怪学习-回城买药加血
比较版本号
SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
dotConnect for PostgreSQL数据提供程序
Button wizard play strange learning - go back to the city to buy medicine and add blood
拥抱平台化交付的安全理念
[Androd] Gradle 使用技巧之模块依赖替换
Thinkphp+redis realizes simple lottery
465. DFS backtracking of optimal bill balance
Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)
机器学习术语
按键精灵打怪学习-自动寻路回打怪点
leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)