Python学习第二十三课——Mysql 表记录的一些基本操作 (查)
查(select * from 表名)
基本语法:
select <字段1,字段2,...> from <表名> where <表达式>;
例如,查询student表中所有的记录,在终端窗口输入命令:
select id,name,age from employee;
也可以查询限定的记录,输入如下命令,可以限定查询结果为第0条到第1条记录,也就是返回第一条记录:
select * from empolyee limit 0,3;
也可以查询通过年龄限制查询
select * from employee where age between 18 and 20;
模糊查询(like):
select * from employee where name like "阿%";
查询空值:
select name from employee where salary is null;
排序查询(order by)
select name,chengji from employee order by chengji;
select name,chengji from employee where chengji>50 order by chengji;
降序查询:
select name,chengji from employee where chengji>50 order by chengji desc;
as 可以添加一个字段:
select name,chengji1+chengji2 as 总成绩 from employee;
select name,chengji1+chengji2 as 总成绩 from employee order by 总成绩;
分组查询 group by :
注意:按分组条件分组每一组只会显示第一条记录;
select * from employee group by name;(按照name分组 name一样的将被分为一组)
Python学习第二十三课——Mysql 表记录的一些基本操作 (查)的更多相关文章
- Python学习第二十二课——Mysql 表记录的一些基本操作 (增删改)
记录基本操作: 增:(insert into) 基本语法: insert into 表名(字段) values(对应字段的值): 例子1: insert into employee(id,name,a ...
- Python学习第二十一课——Mysql 对数据库的基本操作
数据库操作(DDL) 在数据库下创建表(create_table) 创建表代码块: CREATE TABLE employee( id TINYINT PRIMARY KEY auto_increme ...
- Python学习第二十七课——写一个和Django框架的自己的框架
MyWeb框架: from wsgiref.simple_server import make_server def application(environ, start_response): pri ...
- Python学习第二十课——自定property and classmethod
自定制property class Lazyproperty: def __init__(self,func): # print('==========>',func) self.func=fu ...
- Python学习第十三课——re(正则表达式)模块
.的用法 import re s = 'fhsdjakaxdsancjh' # .代表一个元素,完成模糊匹配 res = re.findall("a..x", s) # 找到s中以 ...
- Python学习-第二天-字符串和常用数据结构
Python学习-第二天-字符串和常用数据结构 字符串的基本操作 def main(): str1 = 'hello, world!' # 通过len函数计算字符串的长度 print(len(str1 ...
- Python学习day43-数据库(多表关系)
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- python学习第二次笔记
python学习第二次记录 1.格式化输出 name = input('请输入姓名') age = input('请输入年龄') height = input('请输入身高') msg = " ...
- Python学习day44-数据库(单表及多表查询)
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
随机推荐
- python调用sqlite
参考资料:https://www.liaoxuefeng.com/wiki/1016959663602400/1017801751919456 https://www.cnblogs.com/lia ...
- ONESHELL
没有加 .ONESHELL 的时候,片段中的各行 shell 彼此独立. 加了 .ONESHELL 后,各行shell 可以看作一行 shell. <1> .PHONY: all all: ...
- 下载图片(vue 下载图片)
downloadImg(){ const url = this.imgUrl // window.open(_this.detail.imgUrl) let xmlhttp=new XMLHttpRe ...
- 【vue store的使用方法】(this.$store.state this.$store.getters this.$store.dispatch this.$store.commit)
vue 页面文件 <template> <div> {{this.$store.state.count}}<br/> {{count}}<br/> {{ ...
- 2019牛客暑期多校训练营(第三场) J LRU management 模拟链表操作
输入n, m,n表示n种操作,m表示最多可以容纳m个串. 第一种操作:先在容器里找是否存在这个串,如果不存在,则添加在末尾,这个串携带了一个值v. 如果存在,则先把之前存在的那个拿出来,然后在后面添加 ...
- [爬坑记录] Qt 代码卡住 不发信号 不触发槽
先让我激动一会儿 [捂脸] 最近在用Qt做个程序 用来参加比赛 期间总共遇到两次如标题的问题 也即是 莫名其妙的不触发槽函数了 而且原因也不一样 {先说明 我学习Qt依旧只是入门级 也许入不了大佬法眼 ...
- next.config.js
const configs = { // 编译文件的输出目录 distDir: 'dest', // 是否给每个路由生成Etag generateEtags: true, // 页面内容缓存配置 on ...
- Chrome - 使用 开发者工具 对页面截图
概述 使用 开发者工具 对页面截图 背景 经常需要截图 常用的截图模式有这些 窗口截图 区域截图 gif 问题 Chrome 如何截长图 firefox 好像有插件 1. 解决: 使用 Chrome ...
- 【音乐欣赏】《99》 - MOB CHOIR
曲名:99 作者:MOB CHOIR [00:00.000] 作曲 : 佐々木淳一 [00:00.150] 作词 : 佐々木淳一 [00:00.450] [00:02.370]If everyone ...
- via/route blockage/size blockage/wire/pin guide/pin blockage/partition
1.via 中文名称互连线通孔.我们知道,芯片的连线有不同层的金属互连线相互连接.而Via的作用就是连接这些不同层的金属.如下图所示: 一个完整的通孔是由三层组成的,包括两个互连层和一个cut层,cu ...