#1064 SQL语法错误

时间:2015-11-26 00:49:33

标签: mysql sql

我知道这是一个常见而烦人的问题所以在我要求解释之前我只想说对不起。

正如标题所说,我从我的MySQL数据库中获得了1064语法错误,我导入了php myadmin运行wamp并通过netbeans构建。

我已经检查了其他关于这个问题的帖子,并且已经阅读了有关正确语法的内容,但看不出我的问题是什么。

我非常感激解释,因为我真的想学习这些并提高我的技能。

(如果您对我的代码有任何疑问,请询问)

这是我的完整代码:

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `mydb`
--
CREATE DATABASE IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `mydb`;

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

--
-- Table structure for table `follow`
--

DROP TABLE IF EXISTS `follow`;
CREATE TABLE IF NOT EXISTS `follow` (
`follow_id` int(11) NOT NULL,
`follow_current_user` varchar(255) NOT NULL,
`follow_profile_user` varchar(255) NOT NULL,
`follow_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;

--
-- Dumping data for table `follow`
--

INSERT INTO `follow` (`follow_id`, `follow_current_user`,     `follow_profile_user`, `follow_timestamp`) VALUES
(13, 'dude', 'the', '2015-10-10 03:09:58'),


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

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(11) NOT NULL,
`user_email` varchar(255) NOT NULL,
`user_password` varchar(255) NOT NULL,
`user_firstname` text NOT NULL,
`user_lastname` text NOT NULL,
`user_avatar` varchar(255) NOT NULL,
`user_shortbio` text,
`user_username` varchar(255) NOT NULL,
`user_longbio` text,
`user_facebook` varchar(255) DEFAULT NULL,
`user_twitter` varchar(255) DEFAULT NULL,
`user_linkedin` varchar(255) DEFAULT NULL,
`user_stumbleupon` varchar(255) DEFAULT NULL,
`user_pinterest` varchar(255) DEFAULT NULL,
`user_googleplus` varchar(255) DEFAULT NULL,
`user_website` varchar(255) DEFAULT NULL,
`user_dob` date DEFAULT NULL,
`user_profession` text,
`user_gender` varchar(255) DEFAULT NULL,
`user_maritialstatus` varchar(255) DEFAULT NULL,
`user_address` text,
`user_backgroundpicture` varchar(255) NOT NULL,
`user_joindate` date NOT NULL,
`user_country` varchar(255) DEFAULT NULL,
`user_skype` varchar(255) DEFAULT NULL,
`user_github` varchar(255) DEFAULT NULL,
`user_youtube` varchar(255) DEFAULT NULL,
`user_vimeo` varchar(255) DEFAULT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`user_id`, `user_email`, `user_password`,         `user_firstname`, `user_lastname`, `user_avatar`, `user_shortbio`,     `user_username`, `user_longbio`, `user_facebook`, `user_twitter`,     `user_linkedin`, `user_stumbleupon`, `user_pinterest`, `user_googleplus`,     `user_website`, `user_dob`, `user_profession`, `user_gender`,     `user_maritialstatus`, `user_address`, `user_backgroundpicture`,  `user_joindate`, `user_country`, `user_skype`, `user_github`, `user_youtube`,  `user_vimeo`) VALUES
(1, 'me@gmail.com', '123password123', 'Forname', 'Surname',     '1470024_601216136604826_1065650331_n-884862517.jpg', 'Lorem ipsum.',     'username', 'Lorem ipsum', NULL, NULL, NULL, NULL, NULL, NULL, 'mysite.com',     '1987-11-11', 'Student', 'Male', NULL, 'kablah', 'untitled-90969185.jpg', '2015-    11-11', 'Country', NULL, NULL, NULL, NULL),
--
-- --------------------------------------------------------

--
-- Table structure for table `view`
--

DROP TABLE IF EXISTS `view`;
CREATE TABLE IF NOT EXISTS `view` (
`view_id` int(11) NOT NULL,
`view_profile_user` varchar(255) NOT NULL,
`view_current_user` varchar(255) NOT NULL,
`view_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=123 ;

--
-- Dumping data for table `view`
--

INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`,   `view_timestamp`) VALUES
(65, 'blub', 'rugsworth', '2015-10-18 19:30:56'),


--
-- Indexes for dumped tables
--

--
-- Indexes for table `follow`
--
ALTER TABLE `follow`
ADD PRIMARY KEY (`follow_id`);

--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`), ADD UNIQUE KEY `user_email` (`user_email`), ADD UNIQUE KEY `user_username` (`user_username`);

--
-- Indexes for table `view`
--
ALTER TABLE `view`
ADD PRIMARY KEY (`view_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `follow`
--
ALTER TABLE `follow`
MODIFY `follow_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=18; 
--
-- AUTO_INCREMENT for table `view`
--
ALTER TABLE `view`
MODIFY `view_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=123;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

我认为只是我的代码部分导致了问题:

-- Dumping data for table `user`
--

INSERT INTO `user` (`user_id`, `user_email`, `user_password`,         `user_firstname`, `user_lastname`, `user_avatar`, `user_shortbio`,     `user_username`, `user_longbio`, `user_facebook`, `user_twitter`,     `user_linkedin`, `user_stumbleupon`, `user_pinterest`, `user_googleplus`,     `user_website`, `user_dob`, `user_profession`, `user_gender`,     `user_maritialstatus`, `user_address`, `user_backgroundpicture`,  `user_joindate`, `user_country`, `user_skype`, `user_github`, `user_youtube`,  `user_vimeo`) VALUES
(1, 'me@gmail.com', '123password123', 'Forname', 'Surname',     '1470024_601216136604826_1065650331_n-884862517.jpg', 'Lorem ipsum.',     'username', 'Lorem ipsum', NULL, NULL, NULL, NULL, NULL, NULL, 'mysite.com',     '1987-11-11', 'Student', 'Male', NULL, 'kablah', 'untitled-90969185.jpg', '2015-    11-11', 'Country', NULL, NULL, NULL, NULL),
--
-- --------------------------------------------------------

--
-- Table structure for table `view`
--

DROP TABLE IF EXISTS `view`;
CREATE TABLE IF NOT EXISTS `view` (
`view_id` int(11) NOT NULL,
`view_profile_user` varchar(255) NOT NULL,
`view_current_user` varchar(255) NOT NULL,
`view_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=123 ;

--
-- Dumping data for table `view`
--

INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`,   `view_timestamp`) VALUES
(65, 'blub', 'rugsworth', '2015-10-18 19:30:56'),

1 个答案:

答案 0 :(得分:0)

您的INSERT INTO `view` (`view_id`, `view_profile_user`, `view_current_user`, `view_timestamp`) VALUES (65, 'blub', 'rugsworth', '2015-10-18 19:30:56'); 声明末尾有一个逗号,而不是分号。

应该是:

{{1}}

这样可以修复吗?