1.添加数据返回自增的id字段
<!-- 添加演出厅信息 -->
<insert id="addStudio" parameterType="Studio" useGeneratedKeys="true" keyProperty="studio_id" >
insert into studio (studio_name,studio_row_count,studio_col_count ,studio_introduction )
values( #{studio_name},#{studio_row_count},#{studio_col_count},#{studio_introduction} )
</insert>
获取时的代码:
Studio stu=new Studio();
if (stuDao.addStudio(stu) == 1) {
int id=stu.getStudioId();//获取到id
}
2.mysql查找奇数列数据值:
select parking_id from parking_lot ,(select @rownum :=0) test where (@rownum :=@rownum+1)%2=1;