insert into book value ('红楼梦', '曹雪芹', 100, '清代长篇人情小说');
insert into book(name, author) value ('红楼梦', '曹雪芹');
insert into book values ('三国演义', '罗贯中', 88, '古典小说'),
('水浒传', '施耐庵', 120, '古典小说');
无条件查询:
<1> 查询数据表 book 中的所有信息
select * from book;
<2> 指定列查询
select name, author from book;
select name, author from book where name = '三国演义';
order by 是数据库条件查询中的关键字, 使用时如果不指定升序还是降序, 默认为升序. asc 为升序, desc 为降序.
<1> 升序 asc
select name, price from book order by price asc;
<2> 降序
select name, price from book order by price desc;
<1> 查询价格在 100 以下的书籍
select name, price from book where price < 100;
<2> 查询价格不小于 100 的书籍
select name, price from book where price >= 100;
<3> 查询价格作者是 null 的书籍的信息
select * from book where author is null;
查询价格在 [ 80, 100] 的书的信息
select * from book where price between 80 and 100;
查询价格是 80, 88 的书籍和价格
select name, price from book where price in (80, 88);
<1> % 能匹配多个字符.
select * from book where author like '罗%';
<2> _ 只能匹配多一个字符.
下面这个例子写的是两个_, 看起来不清楚, 像一个.
select * from book where author like '罗__';
将书按名字进行分组(名字一样的是一组, 只显示一次)
select name from book group by name;
修改数据:
update 表名 set 列名1=新数据1,列名2=新数据2列名3=新数据3 where 查询条件
eg: 将名称是三国演义价格是90 的数据改成名字是红岩, 作者是罗广斌, 价格是110, 类别是长篇小说
update book set name = '红岩', author = '罗广斌', price = 110, sort = '长篇小说' where name = '三国演义' and price = 90;
delete from 表名 where 查询条件
delete from book where name = '红旗谱';
OSPF路由协议 OSPF的基本概念和工作过程 开放式最短路径优先协议(OSFP)是基于...
接口与实现 1 接口 2 实现接口 3 接口回调 4 理解接口 5 接口与多态 6 接口变量...
eWebEditor编辑器按钮失效,IE8下eWebEditor编辑器无法使用问题解决方法有两个,...
1. aixcoder安装使用 1.1. 介绍 1.1.1. 功能智能代码提示她用强大的深度学习引擎...
发帖问没有找到答案,今天无意中找一了,哈哈 ConnectorServlet.java文件中有一...
基于Node.js平台的Express教程 Express 简介 什么是 Express Express 能做什么 E...
//js正则实现用户输入银行卡号的控制及格式化 script language="javascript" typ...
本文转载自微信公众号「菜鸟飞呀飞」,作者刘进坤。转载本文请联系菜鸟飞呀飞公...
Elasticsearch 是一个分布式、RESTful 风格的搜索和数据分析引擎,能够解决不断...
本文转载自微信公众号「Java中文社群」,作者磊哥。转载本文请联系Java中文社群...