简体   繁体   English

MySQL INSERT错误操作数应包含1列

[英]MySQL INSERT Error Operand should contain 1 column

I have this MySQL insert query that is giving me a Error Code: 1241. Operand should contain 1 column(s) . 我有这个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);

It works fine, if I only try to insert 1 record at at time, but I thought that INSERT allowed for inserting multiple records in a single statement. 如果我一次只尝试插入1条记录,则工作正常,但我认为INSERT允许在单个语句中插入多个记录。 Any ideas? 有任何想法吗?

PS I know the query is wordy, but that's fine, since it's generated programmatically. PS我知道查询是罗word的,但这很好,因为它是通过编程生成的。

My bad, your query is ok. 我不好,您的查询还可以。 You just have some typos. 你只是有一些错别字。

One extra open brace here: ( ( 3, 这里有一个额外的开放括号: ( ( 3,

And one closing brace here: 69, UNIX_TIMESTAMP(NOW()) ) ) 还有一个右括号: 69, UNIX_TIMESTAMP(NOW()) ) )

Guess if you fix that, everything should work fine. 猜猜如果您解决此问题,一切都应该正常工作。

http://sqlfiddle.com/#!9/1e9f3f/1 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM