insert INTO tst1(id,snkey,data1) VALUES((select id from tst1 where snkey=7 limit 1 ), 1, 8);
解决方案 »
- APMServ5.2.6 mysql提示'root'@'localhost' (using password: YES)
- 大家好,我想问一个关于游标遍历插入新表出现主键重复的问题
- mysql 如何同时Update两条数据到数据库?
- MySQL-Front报错
- 关于MySQL的root用户的安全性
- MySQL的db表被删除了,怎么办
- postgresql返回数据集取不到数是怎么回事啊
- mysql数据库连接错误怎么搞呀??
- mysql 语句优化
- Mysql数据库锁等待问题
- MySql中 select a from (select a,b from table) 报语法错
- mysql中没有intersect关键字怎么搞?
select id from tst1 where snkey=7 limit 1 , 1, 8;
试过了,insert INTO 和 REPLACE INTO 都不可以.
你确定上面的insert 执行不成功?在你的select语句外面加一层括号
mysql> insert INTO tst1(id,snkey,data1) VALUES((select id from tst1 where snkey=8 limit 1 ), 1, 8);
1093 - You can't specify target table 'tst1' for update in FROM clause
mysql>
1093 - You can't specify target table 'tst1' for update in FROM clause
mysql>
mysql> replace INTO tst1(id,snkey,data1) select id from tst1 where snkey=7 limit 1 , 1, 8 ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 8' at line 1
mysql>
replace into d(a,b,c) values((select a from c limit 1),1,1)
insert into d(a,b,c) values((select a from c limit 1),1,1)
limit 1 , 1 ;
insert换成replace能达到要求,谢谢!