gpt4 book ai didi

mysql - 在选择错误中插入...选择除法运算符?

转载 作者:行者123 更新时间:2023-11-29 15:01:22 25 4
gpt4 key购买 nike

如果 XY 不存在则创建表( x 整数不为空, y float 为空, 主键(x) )

INSERT INTO XY (x,y)
(select 1 as x ,(1/7) as y);

错误

Error code 1064, SQL state 42000: 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 'INSERT INTO XY (x,y)
(select 1 as x ,(1/7) as y)' at line 7
Line 1, column 1

有什么想法吗?

最佳答案

您应该在 CREATE TABLE 语句之后(或在 INSERT 语句之前)添加 ;。您正在尝试执行 2 个不带分隔符的不同查询。

CREATE TABLE IF NOT EXISTS XY (
x INT NOT NULL ,
y FLOAT NULL ,
PRIMARY KEY(x)
); # !!! Originally, you missed ;

INSERT INTO XY (x,y)
(select 1 as x ,(1/7) as y);

关于mysql - 在选择错误中插入...选择除法运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2991909/

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