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

边栏推荐
- Excel removes the data after the decimal point and rounds the number
- Trois tâches principales: asynchrone, courrier et timing
- MySQL foundation 06 DDL
- 如今少年已归来,人间烟火气最抚凡人心 复工了~
- 【FPGA教程案例6】基于vivado核的双口RAM设计与实现
- 【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
- dotConnect for PostgreSQL数据提供程序
- 【FH-GFSK】FH-GFSK信号分析与盲解调研究
- 对非ts/js文件模块进行类型扩充
- Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
猜你喜欢

Leetcode 6103 - minimum fraction to delete an edge from the tree
![[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)](/img/ca/1d2473ae51c59b84864352eb17de94.jpg)
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)

Cut point of undirected graph

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

ROS2之ESP32简单速度消息测试(极限频率)

2022.2.14 resumption

合并K个已排序的链表

异步、郵件、定時三大任務

拥抱平台化交付的安全理念

电话网络问题
随机推荐
Strongly connected components of digraph
Every k nodes in the linked list are flipped
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
Leetcode 2097 - Legal rearrangement of pairs
电话网络问题
按键精灵打怪学习-自动回城路线的判断
[day 29] given an integer, please find its factor number
异步、郵件、定時三大任務
Asynchronous, email and scheduled tasks
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
Basic concept and implementation of overcoming hash
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
MySQL foundation 05 DML language
Makefile中wildcard、patsubst、notdir的含义
链表中的节点每k个一组翻转
Kivy tutorial - example of using Matplotlib in Kivy app
Matlab finds the position of a row or column in the matrix
Canvas drawing -- bingdd
R language generalized linear model function GLM, (model fit and expression diagnostics), model adequacy evaluation method, use plot function and car package function
dotConnect for PostgreSQL数据提供程序