我必须根据另一个表的值在表中插入一行,其中只有我要插入process_master_id。其他process_step_master_id和process_srno将是默认值1。 我正在运行以下脚本,但出现“ 操作数应包含1列”错误。我在哪里做错了?
INSERT INTO process_step (process_master_id, process_step_master_id, process_srno)
SELECT (id, "1","1") FROM process_master WHERE id=1;
答案 0 :(得分:4)
您可以将其写为
INSERT INTO process_step(process_master_id, process_step_master_id, process_srno)
values((SELECT id FROM process_master where id = 1),1,1)
答案 1 :(得分:2)
您可以在下面尝试-
INSERT INTO process_step (process_master_id, process_step_master_id, process_srno)
SELECT id, 1,1 FROM process_master WHERE id=1;