MySQL 错误 1064,不知道我在这里做错了什么
mysql -u username -p database -e deletedata.sql
我在第 1 行收到错误 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“deletedata.sql”附近使用的正确语法
DELETE FROM 'table1' WHERE 'column' <= date_sub(current_date, INTERVAL 37 day);
DELETE FROM 'table2' WHERE 'column' <= date_sub(current_date, INTERVAL 37 day);
我可能会缺少什么?
mysql -u username -p database -e deletedata.sql
I get ERROR 1064 (42000) at line 1: 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 'deletedata.sql' at line 1
DELETE FROM 'table1' WHERE 'column' <= date_sub(current_date, INTERVAL 37 day);
DELETE FROM 'table2' WHERE 'column' <= date_sub(current_date, INTERVAL 37 day);
What could I be missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MySQL 中的单引号表示字符串常量。您应该使用反引号 (`) 来转义表/列名称(或一般标识符)。
Single quotes in MySQL denote string constants. You should be using back quotes (`) to escape table / column names (or identifiers in general).
-e 执行一条语句,而不是一个sql文件。
你需要什么:
然后进入 mysql cli:
反斜杠点表示“源文件”
或者你可以直接通过管道传递它:
-e executes a statement, not a sql file.
What you need:
and then into the mysql cli:
Backslash dot means "source file"
Or you can just pipe it:
我想您可能在 FROM 子句中使用表标识符时遇到麻烦。我从我的一个数据库中窃取了一些示例。所以这会失败:
这真的很奇怪,因为只需用“SELECT *”替换“DELETE”就可以了。
但这会很好用:
语法上的奇怪之处。乐趣! :-D
I imagine you're probably getting into trouble with using table identifiers in the FROM clause. I stole some examples from one of my databases. So this will fail:
Which is really strange because just replacing "DELETE" with "SELECT *" works.
But this will work fine:
Syntactic oddities. Fun! :-D