mysql - mySQL 查询中的错误#1064

标签 mysql sql mysql-error-1064

我在下面的查询中得到以下错误:

 #1064 - 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 ')))' at line 1

代码片段:

INSERT INTO test_bans( ip, Expiration )
    VALUES (
    "0.0.0.0", DateAdd(
    "d", 1, Date( )
    )

) 

建表查询

CREATE TABLE test_bans (
            ID smallint(6) NOT NULL AUTO_INCREMENT,
            IP text NOT NULL,
            Expiration DATETIME NOT NULL,
            PRIMARY KEY (ID)
            ) TYPE=MyISAM; 

我错过了什么?

编辑,运行这个查询后我得到了这个错误。我想我的新问题是如何在当前时间戳中添加一天?

#1305 - FUNCTION optimuscprime.DateAdd does not exist 

查询:

 INSERT INTO test_bans( ip, Expiration )
VALUES (
"0.0.0.0", DateAdd(
"d", 1,
CURRENT_TIMESTAMP
)
) 

最佳答案

尝试使用简单的 SQL,而不是 MySQL 方言:

INSERT INTO test_bans( ip, Expiration )
    VALUES (
    '0.0.0.0', (NOW() + INTERVAL 1 DAY)
);

关于mysql - mySQL 查询中的错误#1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2533562/

相关文章:

sql - ORDER BY 子句在 View 、内联函数、派生表、子查询和公用表表达式中无效

mysql - 操作数应包含 1 列

PHP MySQL JSON 查询

sql - 如何在MySQL中随机选择八个项目,每个项目都符合特定条件?

PHP在mysql循环中循环信息

mysql - 为什么这个 Update/Select 子查询是错误的?

C# 在 Windows 窗体应用程序中使用 MySQL 填充和使用组合框中的值

c# - SUM 和 Group after Right Join 两个表

Java JPA 查询

工作台中的 MySql 存储过程