我必须编写一个带有json {mobileno,password和emailId}&的API。返回userId - 在表中自动生成。我的问题是,为此,我必须打两次数据库,首先是插入&然后获取给定mobileNo的用户ID。可以用1个查询来完成,即。如何从insert语句返回userID
列的自动递增值?
我的表:
create table signup
(
userid bigint auto_increment primary key,
mobileNo bigint not null,
password VARCHAR_CASESENSITIVE(255) not null,
emailId varchar(320) not null
);
这是我用于插入行的查询:
jdbcTemplate.update("insert into SignUP (mobileNo, password, emailId) " + "values(?, ?, ?)", new Object[{signup.getMobileNumber(), signup.getPassword(), signup.getEmail()})