一.今日学习内容 1.post方式提交数据 express 中接收 post方式提交的数据需要使用 body-parser 模块 使用 body-parser 来接收表单数据时,表单数据会直接挂载到 req对象的 body属性下,以对象形式保存 1)加载 body-parser 模块 const bodyParser = require('body-parser'); 2)注册为中间件 app.use(bodyParser.urlencoded({extended:false})) {extended:false} 代表使用node的 querystring 模块来解析表单数据 3)使用req对象的body属性来获取表单数据 console.log(req.body) 2.MySQL数据库 多表查询:left join ... on ... select * from 表1 left join 表2 on 链接条件 链接条件一定是 表1的某个字段 = 表2的某个字段 3.添加数据 insert into 表名(字段名1,字段名2,....) values(值1,值2,....) 自增长类型的主键,可以使用null来填充 如果所有字段都会填充数据,则不需要写 表名后的字段列表 4.修改数据 update 表名 set 字段1=值1, 字段2=值2,... where 修改条件 update student set sname='彦',sgender='女',where sno=6 5.删除数据 delete from 表名 where 删除条件 DELETE from student where sno=10
|