2016-05-11 17 views
-2

1064 - SQL構文に誤りがあります。近く '' のtransactionId 'int型(11)DEFAULTのNULLを使用する権利構文についてはMySQLサーバのバージョンに対応するマニュアルを確認し、 PRIMARY KEY(sid)、 KEY pidラインで(pid)12'1064 - SQL構文にエラーがありますか?

-- Table structure for table `products` 
CREATE TABLE IF NOT EXISTS 

`products` (`pid` int(11) NOT NULL AUTO_INCREMENT, 
`product` varchar(255) NOT NULL, 
`product_img` varchar(100) DEFAULT NULL, 
`price` int(11) DEFAULT NULL, 
`currency` varchar(10) DEFAULT 'USD', 
    PRIMARY KEY (`pid`) 
) ENGINE=InnoDB DEFAULT 
CHARSET=latin1 AUTO_INCREMENT=3 ; 

-- 
-- Dumping data for table `products` 
-- 

INSERT INTO `products` (`pid`, `product`, `product_img`, `price`) 
VALUES (1, 'White T-Shirt', 'white.png', 22), (2, 'Black T-Shirt', 'black.png', 30); 

    -------------------------------------------------------- 

    -- Table structure for table `sales` 

    CREATE TABLE IF NOT EXISTS 

`sales` (`sid` int(11) NOT NULL AUTO_INCREMENT, 
`pid` int(11) DEFAULT NULL, 
`uid` int(11) DEFAULT NULL, 
`saledate` date DEFAULT NULL, 
'transactionid' int(11) DEFAULT NULL, 
    PRIMARY KEY (`sid`), 
    KEY `pid` (`pid`), 
    KEY `uid` (`uid`) 
) 

ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ; 

-- 
-- Dumping data for table `sales` 
-- 

INSERT INTO `sales` (`sid`, 

`pid`, `uid`, `saledate`) VALUES 
(1, 2, 1, '0000-00-00'), 
(2, 2, 1, '0000-00-00'), 
(3, 1, 1, '0000-00-00'), 
(6, 2, 1, '2011-03-13'), 
(7, 2, 1, '2011-03-13'), 
(8, 2, 1, '2011-03-13'), 
(9, 2, 1, '2011-03-13'), 
(10, 2, 1, '2011-03-13'), 
(11, 1, 1, '2011-03-13'); 

答えて

0

transactionidの前後の引用符を確認してください。 'の代わりに`を使用する必要があります。

0

この行の構文エラー:

'transactionid' int(11) DEFAULT NULL, 

が、それは、他の列の宣言のようなもの'単一引用符)すべきではないれる列名によって周りの文字を意味し、それは`あるべきはずです(バック・ティック

`transactionid` int(11) DEFAULT NULL, 
関連する問題