"insert into NodeProfileSections (profile_no, tpl_section_no)
select (np.profile_no, tps.tpl_section_no)
from NodeProfile np, TemplateProfileSection tps, TemplateProfile tp
where np.hostname = '%s' AND np.role = '%s' AND tp.tpl_profile_no = tps.tpl_profile_no
AND tp.tpl_name = '%s' AND tp.role = '%s' AND tps.tpl_section_name = '%s';"
%(hostname, role, template_name, role, section_name)
error_message = 'Operand should contain 1 column(s)'
如何解决这个问题?
答案 0 :(得分:5)
从内部选择中删除括号。
q = """INSERT INTO
NodeProfileSections (profile_no,tpl_section_no)
SELECT
np.profile_no
,tps.tpl_section_no
FROM
NodeProfile np
,TemplateProfileSection tps
,TemplateProfile tp
WHERE
np.hostname = '%s'
AND np.role = '%s'
AND tp.tpl_profile_no = tps.tpl_profile_no
AND tpl.tpl_name = '%s'
AND tp.role = '%s'
AND tps.tpl_section_name = '%s'
"""