SQL_MODEを変更するとMYSQLの動作は大きく変わってくる。

ANSI_QUOTES

引用文字 ‘`’ のように、‘”’ を識別子として扱う。文字列の引用文字ではない。このモードを有効にした場合には、
‘`’ を識別子として使用できる。ANSI_QUOTES を有効にした場合には、識別子として解釈されるため、
リテラル文字列の引用には二重引用符を使用できなくなる。


mysql> select comment from string_test limit 1;
+------------+
| comment |
+------------+
| THIS IS LO |
+------------+
1 row in set (0.00 sec)

mysql> select @@SQL_MODE;
+---------------------+
| @@SQL_MODE |
+---------------------+
| NO_AUTO_CREATE_USER |
+---------------------+
1 row in set (0.00 sec)

mysql> select "comment" from string_test limit 1;
+---------+
| comment |
+---------+
| comment |
+---------+
1 row in set (0.00 sec)

mysql> set SQL_MODE ='ANSI_QUOTES';
Query OK, 0 rows affected (0.00 sec)

mysql> select @@SQL_MODE;
+-------------+
| @@SQL_MODE |
+-------------+
| ANSI_QUOTES |
+-------------+
1 row in set (0.00 sec)

mysql> select "comment" from string_test limit 1;
+------------+
| comment |
+------------+
| THIS IS LO |
+------------+
1 row in set (0.00 sec)

mysql>

sql_mode_ansi

————————————————————————-

mysql> SELECT "Let's see whether this works.";
+-------------------------------+
| Let's see whether this works. |
+-------------------------------+
| Let's see whether this works. |
+-------------------------------+
1 row in set (0.00 sec)

mysql> SET sql_mode = 'ANSI_QUOTES';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT "Let's see whether this works.";
ERROR 1054 (42S22): Unknown column 'Let's see whether this works.
mysql> SELECT `Let's see whether this works.`;
ERROR 1054 (42S22): Unknown column 'Let's see whether this works.
mysql> SELECT 'Lets see whether this works.';
+------------------------------+
| Lets see whether this works. |
+------------------------------+
| Lets see whether this works. |
+------------------------------+
1 row in set (0.00 sec)

mysql> SELECT 'Let\'s see whether this works.';
+-------------------------------+
| Let's see whether this works. |
+-------------------------------+
| Let's see whether this works. |
+-------------------------------+
1 row in set (0.00 sec)

sql_mode
————————————————————————-


4.2.6. SQL モード