Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Gotta love when you get descriptive errors like
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax
Can anyone here give me any more of an idea of where I'm going wrong with
CREATE TABLE wp_nas_coffees (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR (100), email VARCHAR (100), company VARCHAR (100), dtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, order VARCHAR (20));
???
order is Mysql reserver word
CREATE TABLE wp_nas_coffees (
id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR (100),
email VARCHAR (100),
company VARCHAR (100),
dtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
tbl_order VARCHAR (20)
);
See MySQL keywords/reserved words
https://dev.mysql.com/doc/refman/5.6/en/keywords.html
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
This is my code
CREATE TABLE mactor(
pid VARCHAR(30) UNSIGNED NOT NULL AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname VARCHAR(30) NOT NULL,
gender VARCHAR(20) NOT NULL,
PRIMARY KEY (pid));
and this is the error
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT null AUTO_INCREMENT,
fname VARCHAR(30) NOT NULL,
lname...' at line 2.
I am very confused and I don't want to use any other values as my primary key other than VARCHAR. please help!
Remove the UNSIGNED; unsigned can only apply to numeric types, not character or binary types. You will also need to get rid of AUTO_INCREMENT; you can't auto increment a character type.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Trying to create a table in MySQL workbench and I keep getting this error message "Error Code: 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 7"
Here is what I have input...what am I doing wrong?
create table members (
id varchar (255) primary key,
pswd varchar(255) not null,
email varchar(255) not null,
member_since timestamp default now() not null,
payment_due decimal (6, 2) not null default 0,
)
;
There is extra comma at the end.
Just remove it and everything works fine.
create table members (
id varchar (255) primary key,
pswd varchar(255) not null,
email varchar(255) not null,
member_since timestamp default now() not null,
payment_due decimal (6, 2) not null default 0)
Db<>fiddle
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
CREATE TABLE demos
(id INT UNSIGNED AUTO_INCREMENT PRIMARY_KEY
first_name VARCHAR NOT NULL
last_name VARCHAR NOT NULL
hometown VARCHAR NOT NULL)
You have an error in your SQL syntax; check the manual that corresponds to
your MariaDB server version for the right syntax to use near 'first_name
VARCHAR NOT NULL last_name VARCHAR NOT NULL hometown VARCHAR NOT...' at line 3
You need to
separate the field definitions with commas;
PRIMARY KEY should be two words separated by a space, not joined with an underscore;
VARCHAR fields need to have a length specified
The following works fine with both MySQL (which you said you're using) and MariaDB (which the error message says you're using):
CREATE TABLE demos
(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(10) NOT NULL,
last_name VARCHAR(10) NOT NULL,
hometown VARCHAR(10) NOT NULL)
db<>fiddle here
You need to add commas after each field in your table, like so:
CREATE TABLE demos (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(10) NOT NULL,
last_name VARCHAR(10) NOT NULL,
hometown VARCHAR(10) NOT NULL
);
EDIT: As the other answer suggests, you also need to specify the default VARCHAR size and separate the keywords PRIMARY and KEY
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I've been trying to create a table, and I can't figure out what's wrong with the syntax. Created other tables just fine. If you could enlighten me, I'd truly appreciate it!
CREATE TABLE `wp_ytvideos`( `ID` VARCHAR NOT NULL, `videoTitle` VARCHAR NULL, `videoOwner` VARCHAR NULL, PRIMARY KEY(`ID`))
Mysql response:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL,
videoTitle VARCHAR NULL,
videoOwner VARCHAR NULL,
P' at line 2
Server version: 10.4.11-MariaDB - mariadb.org binary distribution
VARCHAR columns need a length specified at creation.
CREATE TABLE `wp_ytvideos` (`ID` VARCHAR(255) NOT NULL,
`videoTitle` VARCHAR(255) NULL,
`videoOwner` VARCHAR(255) NULL,
PRIMARY KEY(`ID`))
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
please could you help me with this piece of code, I don't know what's wrong with it. It seems correct at simple glance but it just gets me #1064 syntax error. The MySQL version am running is 5.5
CREATE TABLE mytablename(
-> id SMALLINT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(100) NOT NULL,
-> submission_date NOT NULL TIMESTAMP,
-> PRIMARY KEY (id)
-> )ENGINE=InnoDB;
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 '-> id SMALLINT NOT NULL AUTO_INCREMENT, -> name CHAR(100), ->
submission' at line 2
Remove those arrows and try escaping the column names with backticks:
CREATE TABLE mytablename(
`id` SMALLINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`submission_date` NOT NULL TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;