select * 查詢?nèi)硭凶侄芜@樣寫不好萝究,因?yàn)閿?shù)據(jù)庫隨著業(yè)務(wù)不斷發(fā)展明刷,字段也在不斷增加,查表時要什么查什么跋破,我們可以這樣先定義sql標(biāo)簽比如:
<sql id="Base_Column_List">
id, username, password, email, phone, question, answer, role, create_time, update_time
</sql>
然后這樣
<select id="selectLogin" parameterType="map" resultMap="BaseResultMap">
SELECT
// 使用 include 標(biāo)簽重用重用mybatis的代碼段
<include refid="Base_Column_List" />
from mmall_user
where username = #{username}
and password = #{password}
</select>
updateByPrimaryKeySelective 和 updateByPrimaryKey區(qū)別:
updateByPrimaryKeySelective會對字段進(jìn)行判斷再更新(如果為Null就忽略更新),如果你只想更新某一字段瓶蝴,可以用這個方法毒返。
updateByPrimaryKey對你注入的字段全部更新