執行sql:sql
INSERT INTO user_info(name, age) VALUES (( SELECT u.name FROM user_info u where u.id = 4), 10)
操做成功code
執行sql:blog
INSERT INTO user_info(name, age) VALUES (( SELECT u.name,u.age FROM user_info u where u.id = 4)) 報錯 [SQL] INSERT INTO user_info(name, age) VALUES (( SELECT u.name,u.age FROM user_info u where u.id = 4)) [Err] 1241 - Operand should contain 1 column(s)
問題insert into(c1,c2…… c10) values (v1,v2, (select c3,c4……,c9) from table where 1=1), v10 ),
(v1,v2, (select c3,c4……,c9) from table where 1=1), v10 ),
(v1,v2, (select c3,c4……,c9) from table where 1=1), v10 )
……
sql語句不能執行!?table
-- ---------------------------- -- Table structure for `user_info` -- ---------------------------- DROP TABLE IF EXISTS `user_info`; CREATE TABLE `user_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='用戶表'; -- ---------------------------- -- Records of user_info -- ---------------------------- INSERT INTO `user_info` VALUES ('1', 'aaa', '44'); INSERT INTO `user_info` VALUES ('2', 'bbb', '55'); INSERT INTO `user_info` VALUES ('3', 'ccc', '66'); INSERT INTO `user_info` VALUES ('4', 'aaa', '55'); INSERT INTO `user_info` VALUES ('5', 'bbb', '66'); INSERT INTO `user_info` VALUES ('6', 'aaa', '10'); INSERT INTO `user_info` VALUES ('7', 'aaa', '10');