1064 You have an error in your SQL syntax [duplicate] - mysql

This question already has answers here:
How can I fix MySQL error #1064?
(3 answers)
Closed 2 years ago.
I have had a problem since working with the new MYSQL version 8.0.18.
Always get the same error message:
SQLSTATE [42000]: Syntax error or access violation: 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 'function) VALUES (?,?,?,?,?)
DROP TABLE IF EXISTS bugtracker1_product_status;
CREATE TABLE bugtracker1_product_status (
statusID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
productID INT(10),
statusTitle VARCHAR(255) NOT NULL DEFAULT '',
type ENUM('bug','suggestion') NOT NULL DEFAULT 'bug',
function ENUM('duplicate','solved','outstanding') NOT NULL DEFAULT 'outstanding',
cssClassName VARCHAR(255) NOT NULL DEFAULT '',
showOrder INT(10) NOT NULL DEFAULT 0,
KEY (productID)
);
Where is the problem?
function ENUM('duplicate','solved','outstanding') NOT NULL DEFAULT 'outstanding',
It works in the MariaDB
Thanks for your help!
Thank you for your support, but unfortunately this does not lead to success. The error remains.
`function` ENUM('duplicate','solved','outstanding') NOT NULL DEFAULT 'outstanding',
Could not prepare statement 'INSERT INTO bugtracker1_product_status (productID, statusTitle, cssClassName, type, function) VALUES (?,?,?,?,?)'
Is there no alternative?
FUNCTION (R); became reserved in 8.0.1

function is a reserved keyword in MySQL. You need to escape it with backticks:
`function` ENUM...
The MySQL docs state that it became reserved in version 8.0.1

Related

MySql gives an error for no reason at all? [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 last year.
I am writing an mysql program (using the command line editor):
CREATE TABLE FLIGHTS (
FL_NO VARCHAR(10) NOT NULL PRIMARY KEY,
STARTING VARCHAR(20) NOT NULL,
ENDING VARCHAR(20) NOT NULL,
NO_FLIGTHS INT NOT NULL,
NO_STOPS INT NOT NULL
);
this is somehow gives an error which is surprising. any idea?
Error message:
ERROR 1064 (42000): 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 'STARTING VARCHAR(20) NOT NULL,
ENDING VARCHAR(20) NOT NULL,
NO_FLIGHTS INTEGER N' at line 3
STARTING and ENDING are keywords, and MySql does not accept keywords as column names, changing them should help...

Why would this MySQL query give an error? [duplicate]

This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 5 years ago.
I can't for the life of me figure out what's wrong with this query:
CREATE TABLE IF NOT EXISTS 'plaintext' (
'id' INT NOT NULL AUTO_INCREMENT,
'name' VARCHAR NOT NULL,
'text' TEXT NOT NULL,
PRIMARY KEY ('id')
)
I am running MySQL version 5.7.14 on WAMP. I am getting this 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 ''id' INT NOT
NULL AUTO_INCREMENT, 'name' VARCHAR NOT NULL, 'text' TEX' at line 2
When trying out the query in phpmyadmin it told me that a symbol name and column definition was expected near 'id' on line 2, and there is an unexpected beginning of a statement near 'id' at line 5.
No clue what this even means to be completely honest with you, I'm quite new to MySQL.
Thanks in advance!
David
I think that the issue is that you are not providing a size for your VARCHAR
CREATE TABLE IF NOT EXISTS 'plaintext' (
'id' INT NOT NULL AUTO_INCREMENT,
'name' VARCHAR(100) NOT NULL,
'text' TEXT NOT NULL,
PRIMARY KEY ('id')
)

Cannot create table in mysql workbench

I am trying to add a table to my schema in MySQL workbench and I keep getting an error.
Message Log:
Executing:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '');
Operation failed: There was an error while applying the SQL script to the database.
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 'COMMENT '')' at line 4
SQL Statement:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '')
I have tried to follow a tutorial but I still get the error. There are other tables already on this server and I am able to change their data along with add and delete columns. I am also on the root user.
Barmar answered it above in the comments. This server is using an older version of MySQL so there are not allowed to be COMMENT in the sql. Deleted them and it worked fine.

why this mysql code have error? [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 8 years ago.
i see errors when use this mysql code why?
CREATE TABLE books (
id int(6) unsigned NOT NULL auto_increment,
title varchar(100) NOT NULL default '',
author varchar(100) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (id)
) TYPE=MyISAM;
INSERT INTO books VALUES (1, 'Where God Went Wrong', 'Oolon Colluphid', '24.99');
INSERT INTO books VALUES (2, 'Some More of God\'s Greatest Mistakes', 'Oolon Colluphid', '17.99');
INSERT INTO books VALUES (3, 'Who Is This God Person Anyway?', 'Oolon Colluphid', '14.99');
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 7
Use ENGINE instead of TYPE. The TYPE is long since abandoned.
replace
TYPE=MyISAM;
with
ENGINE=MyISAM;
It is not TYPE anymore. Use the name ENGINE instead:
TYPE keyword is depreciated (since 5.0) and not supported in MySQL5.5
You should use ENGINE instead of TYPE. http://dev.mysql.com/doc/refman/5.1/en/create-table.html

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!