1、修改语句

update 表名 set  where 条件

mysql> update student set birth=1988,department='中文系' where id=901 and name='张老大';

把张老大的出生日期修改为1988,院系修改成中文系

mysql> update student set birth=birth-5;

2、删除语句

删除901同学的,学生信息

mysql> delete from student where id=901;

删除湖南籍学生的信息

mysql> delete from student where address like "湖南%";

清空学生表信息

mysql> delete from student;

3、字符查询like

查询地址为北京的学生信息

mysql> select * from student where address like '北京%';

查询地址为北京市昌平区的学生信息

mysql> select * from student where address like '%北京%平%';

查询湖南籍学生的成绩信息;

mysql> select * from score where stu_id in (select id from student where address like '湖南%');

4、作业

1,把张三的计算机成绩修改成60分

update score set grade=60 where stu_id in(select id from student where name='张三')and c_name='计算机';

2,把计算机科目的分数降低5分

update score set grade=grade-5 where c_name='计算机';

3,把湖南省学生计算机分数提高5分

 update score set grade=grade+5 where c_name='计算机'and stu_id in(select id from student where address like '湖南%');

4,把学号为904的学生,计算机成绩改为85

 update score set grade=85 where c_name='计算机' and stu_id=904;

5,删除904学生的成绩

delete from score where stu_id=904;

6,删除湖南籍贯学生的成绩

 delete from score where stu_id in(select id from student where address like '湖南%'); 

7,删除王姓与张姓同学英语成绩

delete from score where stu_id in (select id from student where name like '王%'or name like '张%') and c_name='英语';

8,删除年纪大于30的学生的计算机成绩

 delete from score where stu_id in (select id from student where 2016-birth>30);

Mysql教程:(六)修改语句、、删除语句、字符查询like的更多相关文章

  1. mysql插入、修改、删除

    联合查询: union:合并.联合,将多次查询结果合并成一个结果 语法: 查询语句1: union[all] 查询语句2: union [all] ... 意义 1.将一条比较复杂的查询语句可拆分成多 ...

  2. MySQL创建、修改、删除数据库

    创建数据库 CREATE DATABASE [IF NOT EXISTS] t1 CHARACTER SET [=] utf8: 中括号中的代码可有可无:CHARATER如果不写则创建为默认的字符. ...

  3. MySQL (六)--外键、联合查询、子查询

    1 外键 外键:foreign key,外面的键(键不在自己表中),如果一张表中有一个字段(非主键)指向另外一张表的主键,那么将该字段称为外键. 1.1 增加外键 外键可以在创建表的时候或创建表之后增 ...

  4. hibernate 实现分页查询语句、单条查询语句、多条查询语句、修改、删除语句

    package com.hanqi.test; import java.util.Date; import java.util.List; import org.hibernate.Query; im ...

  5. Mysql 添加字段 修改字段 删除字段

    1.添加字段(alter.add) mysql> alter table users add name varchar(30) not null after id; 2.修改字段(alter.m ...

  6. 【MySQL】使用trim函数删除两侧字符

    第一个LEADING,可以删除左侧指定的字符以及字符串 SELECT trim(LEADING '/' FROM `path`) 第二个TRAILING,可以删除右侧的指定字符以及字符串 SELECT ...

  7. MySQL表不能修改、删除等操作,卡死、锁死情况的处理办法。

    MySQL如果频繁的修改一个表的数据,那么这么表会被锁死.造成假死现象. 比如用Navicat等连接工具操作,Navicat会直接未响应,只能强制关闭软件,但是重启后依然无效. 解决办法: 首先执行: ...

  8. Mysql教程:(五)多表查询

    多表查询 select name,student.class,student.number,maths,chinese,english from student,score where student ...

  9. MYSQL 删除语句(数据)

    删除数据(DELETE)     如果你失忆了,希望你能想起曾经为了追求梦想的你.   数据库存储数据,总会有一些垃圾数据,也会有一些不需要用的数据了,这些情况下,我们就可以删除这些数据,释放出一定的 ...

  10. 《史上最简单的MySQL教程》系列分享专栏

    <史上最简单的MySQL教程>系列分享专栏 <史上最简单的MySQL教程>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read ...

随机推荐

  1. Windows系统如何找到占用端口的进程并杀掉

    1.先建立用户环境变量:C\WINDOWS/system32 2.输入:cmd,打开命令控制台,然后输入ipconfig 3.再输入:netstat -ano(可以找到所有的进程连接端口及对应PID) ...

  2. linux中如何查看文件上下文

    grep -C 10 keyword catalina.out filename https://blog.csdn.net/weixin_34791683/article/details/11660 ...

  3. phpstoem破解

    https://blog.csdn.net/voke_/article/details/78794567

  4. 解决samba和SELINUX 冲突

    在使用Samba进行建立Window与Linux共享时,要是不能访问,出现"您可能没有权限使用网络资源", 那就是SELinux在作怪了 要是想让共享目录能访问,可以使用命令 #s ...

  5. IDEA连接Mysql数据库之后,在Mapper.xml编写SQL时不会自动提示表信息问题(非常详细!)

    1.首先得连接上数据库 (一)点击IDEA右侧数据库模块 (二)选择MySql进行连接 (三)填写数据库相关配置 (四)重点!!! 这个时候点击测试连接是连接不上的,需要设置时区 (按照如下设置) ( ...

  6. nginx配置禁止爬虫配置

    1.在配置文件里添加禁止爬虫配置 server { ------ #添加如下内容即可防止爬虫 if ($http_user_agent ~* "qihoobot|Baiduspider|Go ...

  7. 学习使用Wpf开源的文本编辑器—smithhtmleditor

    前言 本文主要介绍使用Wpf文本编辑器--smithhtmleditor. 编辑器使用 首先新建一个项目WpfEditor. 然后到Codeplex下载smithhtmleditor. 下载地址:ht ...

  8. 1-基本建表sql语句

    基本的建表语句的总结 --建表语法 CREATE TABLE 表名( --约束可以没有 列名1 数据类型 [约束], 列名2 数据类型 [约束], ......, [约束], ..... ); --该 ...

  9. Python技法2:函数参数的进阶用法

    1.关键字参数(positional argument)和位置参数(keyword argument) Python函数的参数根据函数在调用时(注意,不是函数定义时)传参的形式分为关键字参数和位置参数 ...

  10. 干货分享之Spring框架源码解析01-(xml配置解析)

    记录并分享一下本人学习spring源码的过程,有什么问题或者补充会持续更新.欢迎大家指正! 环境: spring5.X + idea Spring 是一个工厂,是一个负责对象的创建和维护的工厂.它给我 ...