반응형

2. schema 컬럼, 명령어 또는 공통 변수(?) 로 사용되는 이름이 컬럼으로 쓰일때

mysql> create table tb_test1(`schema` varchar(30));

Query OK, 0 rows affected (0.02 sec)

 

mysql> desc tb_test1;

+--------+-------------+------+-----+---------+-------+

| Field  | Type        | Null | Key | Default | Extra |

+--------+-------------+------+-----+---------+-------+

| schema | varchar(30) | YES  |     | NULL    |       |

+--------+-------------+------+-----+---------+-------+

1 row in set (0.01 sec)

 

mysql> select * from tb_test1 where schema = '11';

ERROR 1064 (42000): 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 '= '11'' at line 1

mysql> select * from tb_test1 where `schema` = '11';

Empty set (0.00 sec)

 

schema 는 mysql에서 공통으로 사용되고 있기때문에 에러가 발생되는 것 같다.

그래서 "``" 를 붙여주니 잘 작동하였음.

반응형

'MySQL' 카테고리의 다른 글

ERROR 1201  (0) 2023.09.01
2003, error connecting to master 'replicator@'  (0) 2023.08.24
스토리지 엔진  (0) 2022.10.21
my.cnf  (0) 2022.09.28
1406, Data too long for column 과 STRICT_TRANS_TABLES  (0) 2022.09.28

+ Recent posts