Tom e
Tom e

Reputation: 21

1064 SQL error - don't know how to fix

When I try to upload my SQL file to PHPMyAdmin I receive this error.

SQL query: Dumping data for table data

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),
;

MySQL said: Documentation
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 '' at line 6

phpMyAdmin SQL Dump

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: `datasorter`
--

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

--
-- Table structure for table `data`
--

CREATE TABLE IF NOT EXISTS `data` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`name` varchar(1000) NOT NULL,
`dt` varchar(500) NOT NULL,
`console` varchar(1000) NOT NULL,
`age` varchar(1000) NOT NULL, PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

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

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','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 */;

Upvotes: 0

Views: 93

Answers (3)

Nirnae
Nirnae

Reputation: 1345

You have an extra comma at the end of your query :

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),;
                                     ^^
                                     Here

Just change it to this :

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123');

Upvotes: 0

Osama Jetawe
Osama Jetawe

Reputation: 2705

remove the comma after 'age')

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES (1, 'abc', '1/june/2015', 'abc','123');

Upvotes: 0

Lukasz Szozda
Lukasz Szozda

Reputation: 175616

Remove comma before semicolon:

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),
;

Should be:

INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123');

SqlFiddleDemo

Storing dt as VARCHAR is very bad practice. Consider using proper datatype.

Age shoud be calculated/generated column unless you want to update it every year.

Upvotes: 2

Related Questions