Mysql表
create table table1(
id int(3) zerofill auto_increment primary key,
username varchar(10)
)
engine=innodb;Mysql插入查询
insert into table1 (username)
select id from (select id from table1) as a where
a.id=last_insert_id();我试图通过从同一表和同一行中选择最后一个id插入到一个表中,上面的查询解释了我想要什么do.The插入查询在id和用户名中都给出了空值。预期结果如下。
id username
001 001
002 002
003 003发布于 2013-08-06 22:26:33
为什么要储存价值呢?
CREATE TABLE table1 (
id int(3) zerofill auto_increment PRIMARY KEY
);
CREATE VIEW oh_look_username
AS
SELECT id
, LPad(Cast(id As varchar(10)), 3, '0') As username
FROM table1https://stackoverflow.com/questions/18090786
复制相似问题