mysql双引号表名 [英] mysql double-quoted table names

查看:208
本文介绍了mysql双引号表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行类似mysql的查询:

I'm doing a mysql query like:

Select * from "User";

并返回:

您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以获取在第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 '"User"' at line 1

错误与双引号"有关,我可以保持select语句不变,并使mysql处理双引号吗?

The error has something to do with the double-quotes ", can I keep the select statement as is, and make mysql cope with the double quotes?

推荐答案

来自此帖子:

SET GLOBAL SQL_MODE=ANSI_QUOTES;

我个人进行测试时,必须这样做:

Personally when I tested, I had to do it like this:

SET SQL_MODE=ANSI_QUOTES;

我认为没有其他办法.

http://dev.mysql .com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_ansi_quotes

将"作为标识符引号字符(例如`"引号) 字符),而不是字符串引号字符.您仍然可以使用`" 在启用此模式的情况下引用标识符.启用ANSI_QUOTES后, 您不能使用双引号引起来的文字字符串, 因为它被解释为标识符.

Treat """ as an identifier quote character (like the "`" quote character) and not as a string quote character. You can still use "`" to quote identifiers with this mode enabled. With ANSI_QUOTES enabled, you cannot use double quotation marks to quote literal strings, because it is interpreted as an identifier.

这篇关于mysql双引号表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆