2014-01-30 4 views
-1

나는 이것을 계속 보았고 그 위에 여분의 눈을 얻을 수 있는지 알아 보려고했습니다. create table 쿼리를 실행하려고하는데 작동하지 못하는 것 같습니다. 나는 점점 오전 오류는 여기이 쿼리의 오류는 어디에 있습니까?

#1064 - 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 '`1`, `id_shop` int(11) NOT NULL DEFAULT `1`, `id_lang` int(10) NOT NULL DEFAUL' at line 4 

인 내가

CREATE TABLE IF NOT EXISTS `PREFIX_quote` (
`id_quote` int(10) NOT NULL AUTO_INCREMENT, 
`reference` varchar(9) DEFAULT NULL, 
`id_shop_group` int(11) NOT NULL DEFAULT `1`, 
`id_shop` int(11) NOT NULL DEFAULT `1`, 
`id_lang` int(10) NOT NULL DEFAULT `1`, 
`id_customer` int(10) NOT NULL, 
`total_discounts` decimal(17,2) NOT NULL DEFAULT `0.00`, 
`total_products` decimal(17,2) NOT NULL DEFAULT `0.00`, 
`total_product_wt` decimal(17,2) NOT NULL DEFAULT `0.00`, 
`total_shipping` decimal(17,2) NOT NULL DEFAULT `0.00`, 
`quote_number` int(10) NOT NULL DEFAULT `0`, 
`quote_date` datetime NOT NULL, 
`valid` int(1) NOT NULL DEFAULT `1`, 
`id_employee` int(11) NOT NULL, 
`date_add` datetime NOT NULL, 
`date_upd` datetime NOT NULL, 
PRIMARY KEY (`id_quote`), 
KEY `id_customer` (`id_customer`), 
KEY `id_employee` (`id_employee`)); 
+2

나는이 생각하는 때문에 주제에 특정 오류 메시지 및 코드 예제가 있습니다. 그것은 일반적인 "디버그 내 코드"질문이 아닙니다. – JasonMArcher

답변

4

버리기 정수 주변의 역 따옴표를 실행하려고 쿼리. the fiddle을 참조하십시오.

CREATE TABLE IF NOT EXISTS `PREFIX_quote` (
`id_quote` int(10) NOT NULL AUTO_INCREMENT, 
`reference` varchar(9) DEFAULT NULL, 
`id_shop_group` int(11) NOT NULL DEFAULT 1, 
`id_shop` int(11) NOT NULL DEFAULT 1, 
`id_lang` int(10) NOT NULL DEFAULT 1, 
`id_customer` int(10) NOT NULL, 
`total_discounts` decimal(17,2) NOT NULL DEFAULT 0.00, 
`total_products` decimal(17,2) NOT NULL DEFAULT 0.00, 
`total_product_wt` decimal(17,2) NOT NULL DEFAULT 0.00, 
`total_shipping` decimal(17,2) NOT NULL DEFAULT 0.00, 
`quote_number` int(10) NOT NULL DEFAULT 0, 
`quote_date` datetime NOT NULL, 
`valid` int(1) NOT NULL DEFAULT 1, 
`id_employee` int(11) NOT NULL, 
`date_add` datetime NOT NULL, 
`date_upd` datetime NOT NULL, 
PRIMARY KEY (`id_quote`), 
KEY `id_customer` (`id_customer`), 
KEY `id_employee` (`id_employee`)); 
2

귀하의 값은 백틱 : `1`입니다. 올바르지 않습니다. 이것은 따옴표 안에 있거나, 따옴표로 묶지 않은 숫자이기 때문에.

`id_shop_group` int(11) NOT NULL DEFAULT 1, 

모든 입력란에서이 작업을 수행해야합니다.

4

백틱 (`)은 MySQL에서 identifiers을 인용하는 데 사용되므로 예약어 나 특수 문자가 나타날 수 있습니다. 그들은 종종 종종 불필요한 비록, 당신이하고있는 열 이름을 둘러싸는 데 사용되는,하지만 는 : 기본 값에서 역 따옴표를 제거 :

CREATE TABLE IF NOT EXISTS `PREFIX_quote` (
`id_quote` int(10) NOT NULL AUTO_INCREMENT, 
`reference` varchar(9) DEFAULT NULL, 
`id_shop_group` int(11) NOT NULL DEFAULT 1, 
... 
관련 문제