#1241 - 操作数应包含1列(值)和选择

时间:2015-10-22 07:51:19

标签: mysql

是不是可以在SQL语句中执行这样的操作?

INSERT INTO ships (user_id,construction_time, fleet_id, template_id, experience, hitpoints,unit_4,rof)
        VALUES (11, UNIX_TIMESTAMP(), (-5002), (SELECT id, value_9, value_5, min_unit_4, rof FROM ship_templates WHERE ship_torso >2  ORDER BY RAND() LIMIT 1))

1 个答案:

答案 0 :(得分:1)

将一个表格数据复制到另一个表格: -

INSERT INTO TARGET_TABLE (`col1`,`col2`) SELECT `col1`,`col2` FROM SOURCE_TABLE;

试试这个: -

INSERT INTO ships (ser_id,construction_time, fleet_id, template_id, experience, hitpoints,unit_4,rof) 
SELECT '11',UNIX_TIMESTAMP(),(-5002),id, value_9, value_5, min_unit_4, rof FROM ship_templates WHERE ship_torso >2  ORDER BY RAND() LIMIT 1;