我在mysql中创建一些临时表 更新此表但出现错误
`CREATE TEMPORARY TABLE test (id varchar(50), name varchar(50));
INSERT INTO test (id, name) VALUES (1, 'LF/2019/0001');
SELECT name FROM test;
UPDATE test SET name = (SELECT name FROM test ORDER BY id DESC) + 1 WHERE id = 1;`
Error show : MySQL said: Documentation #1137 - Can't reopen table: 'test'
请帮助, 谢谢,
答案 0 :(得分:-1)
如果您想一次更新该特定列,则可以使用以下脚本
CREATE TEMPORARY TABLE test (id varchar(50), name varchar(50));
INSERT INTO test (id, name) VALUES (1, 'LF/2019/0001');
SELECT name FROM test;
UPDATE test SET name = concat('LF/2019/000',cast((cast(SELECT substring(name,9) FROM test ORDER BY id DESC) as unsigned integer) + 1) as char) WHERE id = '1';
drop table test