mysql error cant fix the error [duplicate] - mysql

This question already has answers here:
How can I fix MySQL error #1064?
(3 answers)
Closed 8 years ago.
I get an error from MySQL:
#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 'TYPE=MyISAM AUTO_INCREMENT=7 AUTO_INCREMENT=7' at line 6
My SQL is:
CREATE TABLE IF NOT EXISTS `default_setup_academic` (
`academic_id` bigint(20) NOT NULL auto_increment,
`academic_name` text NOT NULL,
`academic_order` bigint(20) NOT NULL,
PRIMARY KEY (`academic_id`)
) TYPE=MyISAM AUTO_INCREMENT=7 AUTO_INCREMENT=7 ;
Why does that have an error?

TYPE is no longer in use.
Go with ENGINE
ENGINE=MyISAM

2 issues You have AUTO_INCREMENT=7 2 times and change the type to
ENGINE
CREATE TABLE IF NOT EXISTS
default_setup_academic
(
academic_id bigint(20) NOT NULL auto_increment,
academic_name text NOT NULL,
academic_order bigint(20) NOT NULL,
PRIMARY KEY (academic_id)
) ENGINE=MyISAM AUTO_INCREMENT=7 ;

Related

PhPMyAdmin Error #1064; Syntax Error

I'm trying to put together a MySQL database for a forum, And when I try to make a section table I keep encountering a problem
#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 'TYPE = INNODB' at line 7
Here's the code:
CREATE TABLE sections (
sect_id INT(8) NOT NULL AUTO_INCREMENT,
sect_name VARCHAR(255) NOT NULL,
sect_desc VARCHAR(255) NOT NULL,
UNIQUE INDEX sect_name_unique (sect_name),
PRIMARY KEY (sect_id)
) TYPE=INNODB;
Use the following query
CREATE TABLE IF NOT EXISTS sections (
sect_id INT(8) NOT NULL AUTO_INCREMENT,
sect_name VARCHAR(255) NOT NULL,
sect_desc VARCHAR(255) NOT NULL,
UNIQUE INDEX sect_name_unique (sect_name),
PRIMARY KEY (sect_id)
) ENGINE=InnoDB
To mention the type of engine use ENGINE keyword.

SQL Error - null auto increment

I'm doing a mySQL tutorial to learn how to write sql statements. I keep getting this:
#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 ''add_delete_record' ( 'id' int(11) NOT NULL AUTO_INCREMENT, 'content' text' at line 1
This is the sql I am using:
CREATE TABLE IF NOT EXISTS 'add_delete_record' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'content' text NOT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
This is the exact code the tutorial gave, so I am not sure if the tutorial is just older than my version of mysql(v5.5) or if I have something tiny wrong that I am missing.
You should be using backticks(`) instead of single quotes (').
CREATE TABLE IF NOT EXISTS `add_delete_record` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
sql fiddle
Just remove all single quotes from everywhere the query will run fine.

sql tutorial script error [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
The SQL text that it tells you to copy and paste into phpMyAdmin's SQL page from this tutorial gives me the 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 'TYPE=MyISAM' at line 6
This is the script:
CREATE TABLE `scores` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(15) NOT NULL DEFAULT 'anonymous',
`score` INT(10) UNSIGNED NOT NULL DEFAULT '0'
)
TYPE=MyISAM;
What am I getting wrong here?
It should be ENGINE=MyISAM instead of TYPE=MyISAM.
Yes. TYPE is not work for MyISAM.
**TYPE** must be **ENGINE** .
This is common problem!

error (1064) while creating table in mysql [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
I am using mysql db(version 5.5) and using mysql query browser(v 1.1.5) .But when i try to create a simple table using query browser am getting following error:
CREATE TABLE `tstaks`.`employee` (
`empid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY(`empid`)
)
TYPE = InnoDB;
mysql error no 1064
you have an error in your sql sytax,check the manual that corresponds to your mysqlserver version for right syntax to use
near type ='innoDB
TYPE needs to be ENGINE: ENGINE=InnoDB

mysql query - syntax error - cannot find out why [duplicate]

This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 8 years ago.
im tearing my hair out over this one. A query is throwing an 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 'FROM, SUBJECT, DATE, READ, MAIL ) VALUES ( 'EJackson', 'dfdf', '1270974101', 'fa' at line 1
I printed out the query to see what could be the problem:
INSERT INTO db.tablename ( FROM, SUBJECT, DATE, READ, MAIL ) VALUES ( 'EJackson', 'dfdf', '1270974299', 'false', 'dfdsfdsfd' )
and finaly the structure consists of:
CREATE TABLE db.tablename (
`ID` int(12) NOT NULL auto_increment,
`FROM` varchar(255) NOT NULL,
`SUBJECT` varchar(255) NOT NULL,
`DATE` varchar(255) NOT NULL,
`READ` varchar(255) NOT NULL,
`MAIL` varchar(255) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I can't find anything wrong. Any help would be much appreciated.
In the insert statement, "FROM" is a keyword in SQL so you need to enclose it in backquotes like you have in your create table statement.
So it'll be like:
INSERT INTO db.tablename (`FROM`, `SUBJECT`, `DATE`, `READ`, `MAIL` ) VALUES ( 'EJackson', 'dfdf', '1270974299', 'false', 'dfdsfdsfd' )
Isn't FROM a reserved word in MySQL?