插入查询 INSERT INTO `notifica-6ren">
gpt4 book ai didi

MYSQL 插入查询不起作用显示错误 "Database_Exception [ 1241 ]: Operand should contain 1 column(s)"

转载 作者:行者123 更新时间:2023-11-29 18:42:33 25 4
gpt4 key购买 nike

我尝试过 MySQL 插入查询,但该查询不起作用并显示错误“Database_Exception [1241]:操作数应包含 1 列”。

====>插入查询

INSERT INTO `notifications` (`message`, `selected_numbers`, `creation_date`, `update_date`, `message_date`)
VALUES ('hello testing',
('32', '655', '203', '205', '204', '202', '12', '497', '123', '949', '77', '942', '937', '944', '953', '565', '652', '440', '826', '290', '20', '172', '23', '271', '648', '91', '89', '90', '450', '92', '31', '770', '766', '734', '776', '376', '403', '66', '977', '616', '65', '379', '323', '841', '745', '428', '544', '22', '831', '787'),
1498889053, 1498889053, '07/01/2017');

我尝试在传递数组值中插入单个记录。但这个查询不起作用。

最佳答案

我猜您希望该列表的每个元素进入单独的行,而其他 4 列相同。如果是这样,您可以使用 insert 。 。 。选择并在子查询中生成行:

INSERT INTO `notifications` (`message`, `selected_numbers`, `creation_date`, `update_date`, `message_date`)
SELECT 'hello testing', sn.selected_number,
1498889053, 1498889053, '2017-07-01'
FROM (SELECT '32' as selected_number UNION ALL
SELECT '655' UNION ALL
. . .
SELECT '787'
) sn

关于MYSQL 插入查询不起作用显示错误 "Database_Exception [ 1241 ]: Operand should contain 1 column(s)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44860155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com