概述
错误写法:
-- 执行报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT MAX(sid) +1 FROM `pic_b_timing`, 'MZX20220315001', '01', 'UNDO', 1000, '' at line 2
EXPLAIN INSERT INTO `pic_b_timing`(`sid`, `product_code`, `epolicy_deal_type`, `epolicy_state`, `deal_count`, `mq_flag`, `deal_time`, `time_unit`, `order_type`, `valid`, `timing_type`)
VALUES (SELECT MAX(sid) +1 FROM `pic_b_timing`, 'MZX20220315001', '01', 'UNDO', 1000, '0', NULL, NULL, '01', 1, '03');
正确写法:
-- 取别名执行成功
EXPLAIN INSERT INTO `pic_b_timing`(`sid`, `product_code`, `epolicy_deal_type`, `epolicy_state`, `deal_count`, `mq_flag`, `deal_time`, `time_unit`, `order_type`, `valid`, `timing_type`)
VALUES ((SELECT MAX(sid) +1 FROM `pic_b_timing` a), 'MZX20220315001', '01', 'UNDO', 1000, '0', NULL, NULL, '01', 1, '03');
最后
以上就是知性小蝴蝶为你收集整理的mysql 主键id设置未自增实现id自增插入的全部内容,希望文章能够帮你解决mysql 主键id设置未自增实现id自增插入所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复