我試着輸入該數據爲例學習SQL,但得到這個錯誤#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 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci' at line 5
這是我的SQL代碼:初學者@ SQL:SQL查詢錯誤
CREATE TABLE IF NOT EXISTS `majors` (
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL,
`about` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `majors` (`name`, `price`, `about`) VALUES('Applied Physics', 20.00, 'Applied Physics');
INSERT INTO `majors` (`name`, `price`, `about`) VALUES('Computer Science', 15.00, 'Computer Science');
需要引用'20.00'和'15.00'最後'DEFAULT NULL後刪除逗號,' – 2014-09-20 00:37:10
@ Fred-ii- - 不需要引用小數,但逗號是錯誤。 – sgeddes 2014-09-20 00:38:34
@sgeddes這段時間不會引發錯誤嗎?我認爲它會。 – 2014-09-20 00:39:25