Jump to content

SQL syntax error - please help


trilbyfish

Recommended Posts

I am having a problem when running some code, and i get the following error:

#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 'CREATE TABLE bookingtable3 (
  baynumber tinyint(2) NOT NULL auto_increment,
' at line 2 

 

I do not know why this is because it is automatically generated code.

 

Thanks in advance

Link to comment
Share on other sites

("DROP TABLE IF EXISTS `bookingtable3`;

CREATE TABLE bookingtable3 (
  baynumber tinyint(2) NOT NULL auto_increment,
  08:00 - 09:00 varchar(30) NOT NULL default '',
  09:00 - 10:00 varchar(30) NOT NULL default '',
  10:00 - 11:00 varchar(30) NOT NULL default '',
  11:00 - 12:00 varchar(30) NOT NULL default '',
  12:00 - 13:00 varchar(30) NOT NULL default '',
  13:00 - 14:00 varchar(30) NOT NULL default '',
  14:00 - 15:00 varchar(30) NOT NULL default '',
  15:00 - 16:00 varchar(30) NOT NULL default '',
  16:00 - 17:00 varchar(30) NOT NULL default '',
  id smallint(30) NOT NULL default '0',
  PRIMARY KEY  (baynumber)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;


INSERT INTO bookingtable3 VALUES(1, '-', '-', '-', '-', '-', '-', '-', '-', '-', 1);
INSERT INTO bookingtable3 VALUES(2, '-', '-', '-', '-', '-', '-', '-', '-', '-', 2);
INSERT INTO bookingtable3 VALUES(3, '-', '-', '-', '-', '-', '-', '-', '-', '-', 3);
INSERT INTO bookingtable3 VALUES(4, '-', '-', '-', '-', '-', '-', '-', '-', '-', 4);
INSERT INTO bookingtable3 VALUES(5, '-', '-', '-', '-', '-', '-', '-', '-', '-', 5);
INSERT INTO bookingtable3 VALUES(6, '-', '-', '-', '-', '-', '-', '-', '-', '-', 6);
INSERT INTO bookingtable3 VALUES(7, '-', '-', '-', '-', '-', '-', '-', '-', '-', 7);
INSERT INTO bookingtable3 VALUES(8, '-', '-', '-', '-', '-', '-', '-', '-', '-', ;
INSERT INTO bookingtable3 VALUES(9, '-', '-', '-', '-', '-', '-', '-', '-', '-', 9);
INSERT INTO bookingtable3 VALUES(10, '-', '-', '-', '-', '-', '-', '-', '-', '-', 10);
INSERT INTO bookingtable3 VALUES(11, '-', '-', '-', '-', '-', '-', '-', '-', '-', 11);
INSERT INTO bookingtable3 VALUES(12, '-', '-', '-', '-', '-', '-', '-', '-', '-', 12);
INSERT INTO bookingtable3 VALUES(13, '-', '-', '-', '-', '-', '-', '-', '-', '-', 13);
INSERT INTO bookingtable3 VALUES(14, '-', '-', '-', '-', '-', '-', '-', '-', '-', 14);
INSERT INTO bookingtable3 VALUES(15, '-', '-', '-', '-', '-', '-', '-', '-', '-', 15);
INSERT INTO bookingtable3 VALUES(16, '-', '-', '-', '-', '-', '-', '-', '-', '-', 16);
INSERT INTO bookingtable3 VALUES(17, '-', '-', '-', '-', '-', '-', '-', '-', '-', 17);
INSERT INTO bookingtable3 VALUES(18, '-', '-', '-', '-', '-', '-', '-', '-', '-', 18);
INSERT INTO bookingtable3 VALUES(19, '-', '-', '-', '-', '-', '-', '-', '-', '-', 19);

")

 

Most of the '-' would have names there, but i removed them.

Link to comment
Share on other sites

Um, yeah... a few things:

 

1) you really shouldn't be using tinyint for an auto-increment column.

2) you really shouldn't be using those values as column names.

3) to get it to import, you need to enclose any field name with spaces in backticks (like `this`).

Link to comment
Share on other sites

I've change the column names, but still get the same error.

 

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 '; CREATE TABLE 'bookingtable3' ( `baynumber` varchar(20) NOT NULL auto_increme' at line 1

 

Is the error, and the code is:

 

("DROP TABLE IF EXISTS bookingtable3;
CREATE TABLE 'bookingtable3' (
  `baynumber` varchar(20) NOT NULL auto_increment,
  `eight` varchar(30) NOT NULL default '',
  `nine` varchar(30) NOT NULL default '',
  `ten` varchar(30) NOT NULL default '',
  `eleven` varchar(30) NOT NULL default '',
  `twelve` varchar(30) NOT NULL default '',
  `thirteen` varchar(30) NOT NULL default '',
  `fourteen` varchar(30) NOT NULL default '',
  `fifteen` varchar(30) NOT NULL default '',
  `sixteen` varchar(30) NOT NULL default '',
  `id` smallint(30) NOT NULL default '0',
  PRIMARY KEY  (`baynumber`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

 

Edit: ive changed `baynumber` varchar(20) NOT NULL auto_increment, to `baynumber` int(20) NOT NULL auto_increment, but still the same problem

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.