MySQL 错误代码:1064。您的 SQL 语法有错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19801489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:20:38  来源:igfitidea点击:

MySQL Error Code: 1064. You have an error in your SQL syntax

mysqlsqlsyntax-error

提问by Roy Hinkley

Really, what could possibly be wrong?! It does not get any more simple - the entire query:

真的,可能有什么问题?!它没有变得更简单 - 整个查询:

line 1: use foo
line 2: 
line 3: select * from test_table_1;

Error Code:

错误代码:

  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 'select * from test_table_1' at line 3 0.002 sec
  1. 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 3 行 0.002 秒处的“select * from test_table_1”附近使用的正确语法

The line numbers are for reference only - there not actually in the query window.

行号仅供参考 - 实际上在查询窗口中没有。

I'm trying to run this extremely simple query in MySQLWorkbenchand it's throwing a syntax error.

我正在尝试运行这个极其简单的查询MySQLWorkbench,但它抛出了一个语法错误。

回答by musical_coder

Try adding a semicolon:

尝试添加分号:

use foo;

回答by Hafiz Arslan

Without semicolon both statements will treat as single one. By adding semicolon MySQL will treat both statements as multiple queries. Try using

如果没有分号,两个语句都将视为单个语句。通过添加分号,MySQL 会将这两个语句视为多个查询。尝试使用

 use foo;
    /*and then*/
    select * from foo;