当前位置:网站首页>[SQL brush questions] Day2----SQL syntax basic query
[SQL brush questions] Day2----SQL syntax basic query
2022-08-06 11:47:00 【stair jumping penguin】
Day2----SQLSyntax-Based Query
博主昵称:跳楼梯企鹅
博主主页面链接:博主主页传送门博主专栏页面连接:专栏传送门--网路安全技术
创作初心:本博客的初心为与技术朋友们相互交流,每个人的技术都存在短板,博主也是一样,虚心求教,希望各位技术友给予指导.
博主座右铭:发现光,追随光,成为光,散发光;
博主研究方向:渗透测试、机器学习 ;
博主寄语:感谢各位技术友的支持,您的支持就是我前进的动力 ;
目录
一、Learning to brush questions website
There are a lot of interview questions software on the market. Why do I recommend this website??
一、Learning to brush questions website
1.为什么推荐
Click on the link below to learn brush
Learning URL Links,点击即可进入
There are a lot of interview questions software on the market. Why do I recommend this website??
原因有三
(1)全面
Because the learning resources are very comprehensive,more than technology,There are many learning materials for other industries.
(2)Can be programmed online
在刷题上,often see many websites,Not choice is fills up the topic,No online programming environment
(3)用的人多
Many people who use it indicate that there is a communication technology,More people will answer you,You can solve your own problems as soon as possible
二、基础查询
For the database, the most basic is to add, delete, modify and check.,Then we will specifically review the basics of brushing questions based on additions, deletions, and changes.,By the way, do a test on yourself.命令如下
| 命令 | 含义 |
| create | 增 |
| drop | 删 |
| alter | 改 |
| show | 查 |
三、对数据操作
<1>增加数据
insert into 表名 values(1,2); //添加数据1和数据2
insert into 表名(字段1,字段2) values(1,2);//添加数据1和数据2到字段1和字段2
insert into 表名(字段1,字段2) values(1,2),(3,4);//多数据添加<2>删除数据
delete from 表名 where 条件;<3>更新数据
update 表名 set 字段1=1,字段2=2 where 条件<4>查询数据
select* feom 表名; //查询表中所有数据库
select 字段 from 表名; //查询该表下的字段
select 字段 from 表名 where 条件; //根据指定的条件查询字段(非常常用)
select 字段 from 表名 id between 1 and 5;//查找字段区间为1-5的数据<5>对数据进行排序
select 字段 from 表名 order by 字段 (desc//降序|asc//升序)
举个例子:
select* from studentname order by name,studentid desc, age asc;//很简单是将学生表的学生号进行降序排列,年龄进行升序排列<6>数据进行分组
分组很简单就是group by 的使用学会就可以了
这里主要讲一点:
select * from name limit(偏移量,数量);
其中 偏移量=(n-1)数量<7>多表联合查询
联合这里就需要讲到 and or 的用法,字面意思 and就是和 or就是或
and:
select uname,id,passwd from root and select whoani from admin;//这个肯定同时输出
or:
select uname,id,passwd from root or select whoani from admin;//选择起哄一个输出
四、刷题
<1>查询所有列
题目:

代码:
SELECT id, device_id, gender, age, university, province
FROM user_profile运行截图:

<2>查询多列
题目:

代码:
SELECT device_id,gender,age,university
from user_profile运行截图:

<3>查询结果去重
题目:

代码:
两个解法:
1. 使用DISTINCT:SELECT DISTINCT university from user_profile;
2. 使用group by:SELECT university from user_profile GROUP BY university;
运行截图:

<4>查询结果限制返回行数
题目:

代码:
六种方法:
select device_id from user_profile limit 2;
select device_id from user_profile limit 0,2;
select device_id from user_profile limit 2 offset 0;
select device_id from user_profile where id in(1,2);
select device_id from user_profile where id <=2;
select device_id from user_profile where id=1 or id=2;运行截图:

<5>将查询后的列重新命名
题目:

代码:
SELECT device_id as user_infors_example
FROM user_profile
LIMIT 2运行截图:

五、心得
作为计算机专业的学生,Database terminology or expertise is the most basic.When I study, it is not as I imagined
how hard,Unlimited quizzes,熟能生巧,Continuously hone their technology,strive to be stronger.It must be accumulated knowledge to achieve good results.
边栏推荐
- Understanding MySQL indexes from the ground up
- Kubernetes open source future
- 从ADVANCE.AI 全球产品负责人周洪丞的发言中了解其如何通过产品赋能中国出海企业
- ABP详细教程——模块类
- NITZ time zone update air interface message
- 湖仓一体电商项目(一):项目背景和架构介绍
- Introduction to SQLNET.ALLOWED_LOGON_VERSION parameter in SQLNET.ORA
- Kubernetes daily command
- X32dbg-查找MFC窗口过程函数-跟踪直到满足条件-条件断点-查看窗口句柄
- Su Qiugui: Why do foreign trade companies need to do Google subdivision deployment
猜你喜欢

微信小程序:如何让button中的文字居中

一个国内的占位图服务

CISP-PTE Practical Exercises Explained II (New Edition)

NC1 Addition of Large Numbers

NASA suspends all spacewalks on the International Space Station due to safety issues with spacesuits
How does MySQL implement multi-table query?

CobalStrike(CS)上线隐藏IP和流量

HCIP——VLAN实验

spark跟pycharm整合 ——问题解决

【C# 学习笔记 ①】C# 程序结构和基本语法(VSCode工具配置、数据类型、修饰符、构造函数)
随机推荐
ICDE‘22推荐系统论文梳理之Industry篇
HCIP Day 14 Notes
工作之余想线上学习软件测试靠谱么?
如何成为一名获得Adobe认证的专业人员?
Notion 中文:客户端、网页端汉化方案
链路聚合简述
线程池需要关闭吗?使用线程池出现内存泄露的详细分析
NC1 Addition of Large Numbers
2022年注册谷歌账号手机号不能验证?Google账号注册最后一步卡在此号码无法用于验证上的成功解决技巧
【C# 学习笔记 ①】C# 程序结构和基本语法(VSCode工具配置、数据类型、修饰符、构造函数)
NITZ time zone update air interface message
因宇航服存在安全问题 NASA叫停国际空间站所有太空行走任务
从ADVANCE.AI 全球产品负责人周洪丞的发言中了解其如何通过产品赋能中国出海企业
Go-Excelize API源码阅读(二)——OpenFile()
P1866 Number
解密一颗芯片设计的全生命周期算力需求
P1747 What a strange game
#yyds干货盘点#range() 函数
kubernetes 常见架构图
主板故障!教你如何用主板诊断卡检测维修电脑主板故障
