sql查询注意

select * 查询全表所有字段这样写不好,因为数据库随着业务不断发展,字段也在不断增加,查表时要什么查什么,我们可以这样先定义sql标签比如:

 
    id, username, password, email, phone, question, answer, role, create_time, update_time
 

然后这样

  

updateByPrimaryKeySelective 和 updateByPrimaryKey区别:

updateByPrimaryKeySelective会对字段进行判断再更新(如果为Null就忽略更新),如果你只想更新某一字段,可以用这个方法。
updateByPrimaryKey对你注入的字段全部更新

你可能感兴趣的:(sql查询注意)