当前位置:网站首页>MySQL learning Day1 DDL, DML, DQL basic query
MySQL learning Day1 DDL, DML, DQL basic query
2022-07-27 18:33:00 【Z know and do t】
Day1
One 、DDL、DML
1.1 MySQL Log in to exit
What is? sql?
Structured Query Language: Structured query language
In fact, it defines the rules for operating all relational databases 
1.2 General grammar

1.3 SQL classification


1.4 DDL Operating the database _ establish & Inquire about
DDL(Data Definition Language) Data definition language :
Used to define database objects : database , surface , Column, etc. , keyword create、drop、alter etc.

Operating the database :CRUD
*C(create) : establish * R(Retrieve): Inquire about show databases Query all databases * U(Update): modify * D(Delete) Delete * Using a database
1.4 DDL Operating the database _ modify 、 Delete 、 Use

1.5 DDL Operation table - Inquire about 、 establish
show tables: Query all table names in a database
desc Table name : Query table structure
Copy table :create table indicate like Copied indication 
1.6 DDL Operation table - modify 、 Delete


1.6 DML_ add to 、 Delete —— Modifying data

Modifying data 
Two 、DQL
2.1 Inquire about


2.2 Conditions of the query


CREATE TABLE student (
id INT, -- Number
NAME VARCHAR(20), -- full name
age INT, -- Age
sex VARCHAR(5), -- Gender
address VARCHAR(100), -- Address
math INT, -- mathematics
english INT -- English
);
INSERT INTO student (id, NAME, age, sex, address, math, english) VALUES (1, ' Jack ma, ',55,' male ',' Hangzhou ' ,66,78),
(2,' ma ',45, ' Woman ',' Shenzhen ',98,87),(3, ' Ma Jingtao ',55,' male ',' Hong Kong ',56,77), (4, ' Liu Yan ',20, ' Woman ', ' hunan ',76,65),
(5,' Liu Qing ',20, ' male ',' hunan ' ,86,NULL),(6, ' Lau Andy ',57,' male ',' Hong Kong ',99,99), (7, ' Mard ' ,22, ' Woman ',' Hong Kong ',99,99),
(8, ' De Marcia ',18, ' male ', ' nanjing ',56,65);
SELECT * FROM student;
-- Search for name and age
SELECT NAME,age FROM student;
-- Remove duplicate result sets
SELECT DISTINCT address FROM student;
SELECT NAME,address FROM student;
-- Calculation math and english Sum of scores
SELECT NAME,math,english,math + english FROM student;
-- If there is a null Operations involved , The results are all null IFNULL function
SELECT NAME,math,english,math + IFNULL (english,0) FROM student;
-- names
SELECT NAME,math mathematics ,english English ,math + IFNULL (english,0) Total score FROM student;
-- Query age is greater than 20
SELECT * FROM student WHERE age > 20;
SELECT * FROM student WHERE age >= 20;
-- Inquiry age is not equal to 20
SELECT * FROM student WHERE age != 20;
SELECT * FROM student WHERE age <> 20;
-- Age Greater than or equal to 20 Less than or equal to 30
SELECT * FROM student WHERE age >=20 && age <=30;
SELECT * FROM student WHERE age BETWEEN 20 AND 30;
-- Check age 22 year ,18 year ,25 Age information
SELECT * FROM student WHERE age = 22 OR age = 18 OR age = 25;
SELECT * FROM student WHERE age IN (22,18,25);
-- The English score is null ,null Value cannot be used = != Judge
SELECT * FROM student WHERE english IS NULL;
-- The English score is not null
SELECT * FROM student WHERE english IS NOT NULL;
-- Find out what's the name of Ma ?
SELECT * FROM student WHERE NAME LIKE ' Horse %';
-- The second word in the query name is the person
SELECT *FROM student WHERE NAME LIKE '_ turn %';
-- Query the person whose name contains the horse
SELECT * FROM student WHERE NAME LIKE '% Horse %';
边栏推荐
- Solve the problem that reids cannot be accessed by other IPS
- 2. 改变颜色空间及颜色检测
- Deep learning: Gan optimization method dcgan case
- 微信小程序获取手机号
- Uniapp has no effect on the page selector on the app side
- Deep learning: Gan case exercise -minst handwritten digits
- Wechat applet wxacode.getunlimited generates applet code
- 3. opencv几何变换
- Visual Studio Code安装教程(超详细)
- Publish your own NPM component library
猜你喜欢

深度学习:GAN案例练习-minst手写数字

Binary tree concept

发布自己的npm组件库

Error launching IDEA

2021.7.30笔记 索引

3. Opencv geometric transformation

How do corporate giants such as Schneider Electric and L'Oreal make open innovation? Uncover secrets of demo World Innovation Summit

微信小程序获取openId, sessionKey, unionId

2021.8.1笔记 DBA
![[MIT 6.S081] Lab 9: file system](/img/f5/ea30b1fe5b6d73c86f2509c690ca20.png)
[MIT 6.S081] Lab 9: file system
随机推荐
Announcing the acquisition of 30% shares of Wenye, what is the general intention of Dalian United?
[mit 6.s081] LEC 10: multiprocessors and locking notes
微信小程序微信支付概述
2021.8.9笔记 request
[MIT 6.S081] Lab8: locks
Common commands of database 2
1. OpenCV image basic operation
Solution to invalid SQL Server connection to server
XML学习 Day1 : xml / Jsoup解析器 / selector选择器 /Xpath选择器
动态链表3队列的链式存储结构(LinkedQueue实现)
JDBC学习 Day1:JDBC
Deep learning - paper reading: action structural graph convolution network as-gcn
2021.7.18 notes MySQL data type
An analysis of CPU explosion of a smart logistics WCS system in.Net
软件安装相关
Visual Studio Code安装教程(超详细)
NVIDIA released the world's smallest edge AI supercomputing: 21tops computing power, power consumption is only 10W!
The end of another era!
[MIT 6.S081] Lab 3: page tables
Huawei mate30 Pro 5g disassembly: self developed chips account for more than half, and American chips still exist!