mysql学习相关

多条件表查询为空时查询全部

 let sql = `select * from user where (userId=? or ?='') and (createTime between ? and ? or ?='')`;
let sqlVal =[reqData.userId,reqData.userId,reqData.beginTime,reqData.endTime,reqData.beginTime]
    conn.query(sql,sqlVal, (e, r) => {
         if(e) throw e;
        res.json(new Result({msg:'获取成功',data:r}))
})

创建表后,将某个字段设置为自增主键

alter table user add primary key (id);

鼠标点操作


自增.png

你可能感兴趣的:(mysql学习相关)