Blogger Information
Blog 34
fans 2
comment 0
visits 23299
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
11月21号 SQL语句
遗忘了寂寞
Original
501 people have browsed it

1、创建表

2、SQL语句

2.1、插入数据

  1. INSERT INTO `gdtype` (`code`,`name`,`gdtypeid`,`unit`,`sprice`,`price`)
  2. VALUES('K003','中学作品集',1,'本',50,30),
  3. ('K004','小学生百强作文集',1,'本',50,30),
  4. ('K005','七彩语文',1,'本',100,80),
  5. ('K006','DVD',2,'套',1500,1000),
  6. ('K007','家庭影院',2,'套',2000,1500),
  7. ('K008','功放机',2,'套',1000,800),
  8. ('K009','彩电',2,'台',4500,3000),
  9. ('K010','麦克风',2,'个',150,100),
  10. ('K011','AV线',3,'条',15,10),
  11. ('K012','电源线',3,'条',15,10),
  12. ('K013','视频线',3,'条',15,10),
  13. ('K014','显示器',4,'台',1500,1000),
  14. ('K015','鼠标键盘套装',4,'套',150,100),
  15. ('K016','联想电脑',4,'台',5500,3000),
  16. ('K017','戴尔电脑',4,'台',6500,4000),
  17. ('K018','小米笔记本',4,'台',5500,3000)


2.2、更新数据

  1. -- 更新goods表中nameDVD的值修改DVD套装
  2. UPDATE `goods` SET `name` ='DVD套装' WHERE `name`='DVD'


2.3、查询数据

  1. -- 查询出gdtypeid2的数据
  2. SELECT * FROM `goods` WHERE `gdtypeid` = 2

2.4、多表查询(内联)

  1. -- 查询出分类名为“家电”的商品
  2. SELECT
  3. a.*, b.`name` AS fl_name
  4. FROM
  5. `goods` AS a
  6. INNER JOIN `gdtype` AS b ON a.`gdtypeid` = b.`gdtypeid`
  7. WHERE
  8. b.`name` = '家电'

2.5、删除数据

  1. -- 删除goodsid=1的商品
  2. DELETE FROM `goods` WHERE `goodsid`=1



手写代码


Correcting teacher:查无此人查无此人

Correction status:qualified

Teacher's comments:完成的不错,继续努力
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post