我有一个MySQL插入查询,它给了我一个Error Code: 1241. Operand should contain 1 column(s)。
INSERT INTO esjp_content
( esjp_content.primary_key, esjp_content.template_id, esjp_content.section_ref,
esjp_content.position, esjp_content.indent, esjp_content.content,
esjp_content.summary_id, esjp_content.role_ref, esjp_content.author_id,
esjp_content.event_id, esjp_content.sys_time )
VALUES
( ( 3, 1, 1, 0, 0, 'Some test content.', 0, 1, 1, 69, UNIX_TIMESTAMP(NOW()) ),
( 4, 1, 1, 1, 1, 'Some test content2.', 0, 1, 1, 69, UNIX_TIMESTAMP(NOW()) ) )
ON DUPLICATE KEY UPDATE
esjp_content.primary_key=VALUES(esjp_content.primary_key),
esjp_content.template_id=VALUES(esjp_content.template_id),
esjp_content.section_ref=VALUES(esjp_content.section_ref),
esjp_content.position=VALUES(esjp_content.position),
esjp_content.indent=VALUES(esjp_content.indent),
esjp_content.content=VALUES(esjp_content.content),
esjp_content.summary_id=VALUES(esjp_content.summary_id),
esjp_content.role_ref=VALUES(esjp_content.role_ref),
esjp_content.author_id=VALUES(esjp_content.author_id),
esjp_content.event_id=VALUES(esjp_content.event_id),
esjp_content.sys_time=VALUES(esjp_content.sys_time);如果我只尝试在一次插入1条记录,它就可以正常工作,但我认为INSERT允许在一条语句中插入多条记录。有什么想法吗?
我知道这个查询很冗长,但这很好,因为它是以编程方式生成的。
发布于 2016-06-29 15:52:21
我的错,你的询问没问题。你只是有一些排字。
这里有一个额外的开口支撑:( ( 3,
这里还有一个关闭支撑:69, UNIX_TIMESTAMP(NOW()) ) )
如果你修好了,一切都会好起来的。
http://sqlfiddle.com/#!9/1e9f3f/1
INSERT INTO esjp_content
( esjp_content.primary_key, esjp_content.template_id, esjp_content.section_ref,
esjp_content.position, esjp_content.indent, esjp_content.content,
esjp_content.summary_id, esjp_content.role_ref, esjp_content.author_id,
esjp_content.event_id, esjp_content.sys_time )
VALUES
( 3, 1, 1, 0, 0, 'Some test content.', 0, 1, 1, 69, NOW() ),
( 4, 1, 1, 1, 1, 'Some test content2.', 0, 1, 1, 69, NOW() + INTERVAL 1 DAY )
ON DUPLICATE KEY UPDATE
esjp_content.primary_key=VALUES(esjp_content.primary_key),
esjp_content.template_id=VALUES(esjp_content.template_id),
esjp_content.section_ref=VALUES(esjp_content.section_ref),
esjp_content.position=VALUES(esjp_content.position),
esjp_content.indent=VALUES(esjp_content.indent),
esjp_content.content='updated',
esjp_content.summary_id=VALUES(esjp_content.summary_id),
esjp_content.role_ref=VALUES(esjp_content.role_ref),
esjp_content.author_id=VALUES(esjp_content.author_id),
esjp_content.event_id=VALUES(esjp_content.event_id),
esjp_content.sys_time=VALUES(esjp_content.sys_time);https://stackoverflow.com/questions/38104072
复制相似问题