RobotSun
RobotSun

Reputation: 1

Error #1064 - SQL syntax error

First and foremost, I am a total novice when it comes to SQL, and I'm trying to build a database for my web design course. Having tried a thorough google search and exploring some of the answers here, I'm still no closer to figuring out what my problem is. The error that keeps getting thrown out is the title of this question, but this is the code I have so far:

Table structure for table `members`

create database glasgowboys;
use glasgowboys;

CREATE TABLE `members` 
(`ID` int(11) NOT NULL AUTO_INCREMENT,
`Email` varchar(255) NOT NULL,
`Password` varchar(50) NOT NULL,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,) 
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

I've been through several similar questions on stackoverflow, following their advice on replacing quotes with backticks, but with no luck.

Upvotes: 0

Views: 61

Answers (2)

PMF
PMF

Reputation: 17185

Around table or field names, you must put "[]", not "'" and certainly not "`".

This should be

CREATE TABLE members
([ID] int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
[Email] varchar(255) NOT NULL,
[Password] varchar(50) NOT NULL,
[FirstName] varchar(255) NOT NULL,
[LastName] varchar(255) NOT NULL) 
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

(Maybe still not exactly correct, I only have Sql Server for testing around just now)

Upvotes: 0

Aziz Shaikh
Aziz Shaikh

Reputation: 16524

When using auto_increment, make the field primary key. Also, remove the extra , after the last field definition.

Try this:

CREATE TABLE `members` 
(`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Email` varchar(255) NOT NULL,
`Password` varchar(50) NOT NULL,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL) 
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Upvotes: 1

Related Questions