建网站要学哪些软件,大连网站建设特色,邢台市信都区,wordpress 建站公司1. MySQL 案例
1.1. 设计数据库 1、首先根据相关业务需求(主要参考输出输入条件)规划出表的基本结构 2、根据业务规则进行状态字段设计 3、预估相关表的数据量进行容量规划 4、确定主键 5、根据对相关处理语句的分析对数据结构进行相应的变更。 设计表的时…1. MySQL 案例
1.1. 设计数据库 1、首先根据相关业务需求(主要参考输出输入条件)规划出表的基本结构 2、根据业务规则进行状态字段设计 3、预估相关表的数据量进行容量规划 4、确定主键 5、根据对相关处理语句的分析对数据结构进行相应的变更。 设计表的时候每个表的功能要独立优点:结构清晰操作数据库的时候提高性能
1.2. 实现数据库 1新建user表 2新建order表 3新建product表 4新建category表
1.3. 操作数据库
1.3.1. 插入记录
insert into 表名(列名1,列名2,列名3……) values (值1,值2,值3……)1.3.2. 修改表记录
update 表名 set 字段名值字段名值字段名值…… where 条件1.3.3. 删除表记录
delete from 表名 where id4;1.3.4. 查询操作语法
select [distinct]*| 列名列名 from 表名 [where条件]1查询所有商品
select * from category;2查询商品名和商品价格
SELECT product_name,product_price FROM product;3查询商品名使用列别名
select product_name as “商品名称” from product;4去掉重复值(按照价格)
select distinct(product_price) from product;5将所有的商品的价格10进行显示
select product_name, product_price10 from product ;1.3.5. 条件查询 1查询商品名称为华为pura70的商品信息
select * from product where product_name华为pura70;2查询商品名称含有pura字的商品信息(模糊查询)
select * from product where product_name like %pura%;3查询商品id在(1,3)范围内的所有商品信息
select * from product where product_id in (1,3);4查询商品名称含有pura”字并且id为2的商品信息
select * from product where product_name like %pura%and product_id2;5查询id为1或者3的商品信息
select * from product where product_id1 or product_id3;1.3.67 排序 1查询所有的商品按价格进行排序(升序、降序)
select * from product order by product_price asc;
select * from product order by product_price desc;2查询名称査pura的商品信息并且按照价格降序排序
select * from product where product_name like %pura% order by product_price desc;1.3.6. 聚合函数 1获得所有商品的价格的总和
select sum(product_price) from product;2获得所有商品的平均价格
select avg(product_price) from product;3获得所有商品的个数
select count(product_name) from product;1.3.7. 分组操作 1根据category_id字段分组
select category_id,count(*) from product group by category_id;2根据category_id分组分组统计每组商品的平均价格并且平均价格大于200元
select category_id,avg(product_price) from product group by category_id having avg(product_price)200;