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

边栏推荐
- leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】
- 按键精灵打怪学习-多线程后台坐标识别
- MySQL foundation 07-dcl
- Inversion de l'intervalle spécifié dans la liste des liens
- 电话网络问题
- Arduino DY-SV17F自动语音播报
- SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
- 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
- [shutter] image component (cached_network_image network image caching plug-in)
- 每日一题之干草堆的移动
猜你喜欢

What is needed to develop a domestic arm intelligent edge computing gateway
![[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)

【C语言】指针与数组笔试题详解

leetcode:701. 二叉搜索树中的插入操作【bst的插入】

leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】

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

Understanding and distinguishing of some noun concepts in adjustment / filtering

Correctly distinguish the similarities and differences among API, rest API, restful API and web service

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

Leetcode 6103 - minimum fraction to delete an edge from the tree
随机推荐
Button wizard play strange learning - go back to the city to buy medicine and add blood
机器学习术语
拥抱平台化交付的安全理念
ROS2之ESP32简单速度消息测试(极限频率)
Kivy教程大全之如何在 Kivy 中创建下拉列表
关于Fibonacci数列
JS inheritance and prototype chain
Foundations of data science is free to download
Basic concept and implementation of overcoming hash
2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
Kivy tutorial how to create drop-down lists in Kivy
[FPGA tutorial case 5] ROM design and Implementation Based on vivado core
leetcode 2097 — 合法重新排列数对
链表中的节点每k个一组翻转
每日一题之干草堆的移动
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
dotConnect for PostgreSQL数据提供程序
Key wizard play strange learning - multithreaded background coordinate recognition
Explain the basic concepts and five attributes of RDD in detail
matlab 多普勒效应产生振动信号和处理