查(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 表记录的一些基本操作 (查)的更多相关文章

  1. Python学习第二十二课——Mysql 表记录的一些基本操作 (增删改)

    记录基本操作: 增:(insert into) 基本语法: insert into 表名(字段) values(对应字段的值): 例子1: insert into employee(id,name,a ...

  2. Python学习第二十一课——Mysql 对数据库的基本操作

    数据库操作(DDL) 在数据库下创建表(create_table) 创建表代码块: CREATE TABLE employee( id TINYINT PRIMARY KEY auto_increme ...

  3. Python学习第二十七课——写一个和Django框架的自己的框架

    MyWeb框架: from wsgiref.simple_server import make_server def application(environ, start_response): pri ...

  4. Python学习第二十课——自定property and classmethod

    自定制property class Lazyproperty: def __init__(self,func): # print('==========>',func) self.func=fu ...

  5. Python学习第十三课——re(正则表达式)模块

    .的用法 import re s = 'fhsdjakaxdsancjh' # .代表一个元素,完成模糊匹配 res = re.findall("a..x", s) # 找到s中以 ...

  6. Python学习-第二天-字符串和常用数据结构

    Python学习-第二天-字符串和常用数据结构 字符串的基本操作 def main(): str1 = 'hello, world!' # 通过len函数计算字符串的长度 print(len(str1 ...

  7. Python学习day43-数据库(多表关系)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  8. python学习第二次笔记

    python学习第二次记录 1.格式化输出 name = input('请输入姓名') age = input('请输入年龄') height = input('请输入身高') msg = " ...

  9. Python学习day44-数据库(单表及多表查询)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

随机推荐

  1. 使用Samba实现文件共享:Windows和Linux之间

    1.概述: 1987 年,微软公司和英特尔公司共同制定了 SMB(Server Messages Block,服务器消息 块)协议,旨在解决局域网内的文件或打印机等资源的共享问题,这也使得在多个主机之 ...

  2. 2019 ICPC 徐州网络赛 B.so easy (并查集)

    计蒜客链接:https://nanti.jisuanke.com/t/41384 题目大意:给定n个数,从1到n排列,其中有q次操作,操作(1) 删除一个数字 // 操作(2)求这个数字之后第一个没有 ...

  3. IntelliJ IDEA 2017.3尚硅谷-----界面展示

  4. (matlab)自定义图像(matlab)

    clc;clear all;A=[0 230 255 60 30 100];A=uint8(A);imshow(A,'InitialMagnification','fit') 如图: clc;clea ...

  5. Bugku-CTF之前女友(SKCTF)

    Day35    前女友(SKCTF) http://123.206.31.85:49162/ flag格式:SKCTF{xxxxxxxxxxxxxxxxxx}  

  6. bugku 散乱密码

    BugkuCTF_加密_散乱的密文 WriteUp   image.png lf5{ag024c483549d7fd@@1} 一张纸条上凌乱的写着2 1 6 5 3 4 以前做过这种类型的 既然是凌乱 ...

  7. php截取富文本框中的固定长度的字符

    ai,哎怎么赶脚自己写东西越来越小儿科了呢,现在连这个问题都找了好半天 因为后台是的内容是富文本编辑器编辑的,前台我傻逼的直接截取了字符串,然后样式啥的都乱了,找了半天是因为富文本的问题 其实解决办法 ...

  8. 吴裕雄 python 机器学习——支持向量机SVM非线性分类SVC模型

    import numpy as np import matplotlib.pyplot as plt from sklearn import datasets, linear_model,svm fr ...

  9. ACM的探索之Everything Is Generated In Equal Probability(这真的是很有趣的话语丫!)

    ---------------------------------------步履不停,奋勇前进! ------------------------难度真的是蛮大丫!后序补充!

  10. java.util.Properties类,保存时保留注释及格式不变

    原文地址:http://blog.csdn.net/benbenxiongyuan/article/details/53006097 参考地址:http://www.iteye.com/topic/1 ...