Blogger Information
Blog 34
fans 0
comment 0
visits 22398
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
11月20日—mysql数据库增删查改操作
曾龙宇
Original
530 people have browsed it

增删查改操作

插入数据
  1. INSERT INTO `person` (`username`,`password`,`realname`,`age`,`email`,`sex`,`phone`,`mobile`,`address`,`status`)
  2. VALUES('admin','123456','张三',25,'123456@qq.com',1,'0769-87767612','13800138000','东莞市',1);
更新数据
  1. UPDATE `person` SET `username`='zhangsan' WHERE id=1;
删除数据
  1. DELETE FROM `person` WHERE id=2;
查询数据
  1. SELECT * FROM `person` where id=1;
  2. SELECT * FROM `student` WHERE collegeId=1 LIMIT 0,5;

学习创建数据表

多表查询

内连接

内连接就是表间的主键与外键相连,只取得键值一致的,可以获取双方表中的数据连接方式

  1. SELECT a.name,a.phone,b.collegeName
  2. FROM `student` as a
  3. INNER JOIN `college` as b
  4. ON a.collegeId = b.collegeId;

左连接

左连接是以左表为标准,只查询在左边表中存在的数据,当然需要两个表中的键值一致

  1. SELECT a. NAME,a.phone,b.collegeName
  2. FROM`student` AS a
  3. LEFT JOIN `college` AS b
  4. ON a.collegeId = b.collegeId;

右连接

右连接将会以右边作为基准,进行检索

  1. SELECT a. NAME,a.phone,b.collegeName
  2. FROM`student` AS a
  3. RIGHT JOIN `college` AS b
  4. ON a.collegeId = b.collegeId;

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