MySQL INSERT 错误操作数应包含 1 列
MySQL INSERT Error Operand should contain 1 column
我有这个 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
允许在单个语句中插入多条记录。有什么想法吗?
P.S。我知道查询很冗长,但没关系,因为它是通过编程生成的。
不好意思,你的查询没问题。你只是有些错别字。
这里多了一个左大括号:( ( 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);
我有这个 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
允许在单个语句中插入多条记录。有什么想法吗?
P.S。我知道查询很冗长,但没关系,因为它是通过编程生成的。
不好意思,你的查询没问题。你只是有些错别字。
这里多了一个左大括号:( ( 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);