#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
i have got that problem, but i cannot realize where is the mistake.
i've read mysql error documentation, and it says the error is about parse. but i still dont understand yet, thank for your help.
here is an sql query :
CREATE TABLE IF NOT EXISTS produk_detil (
id_produk varchar( 10 ) NOT NULL ,
short_desc text NOT NULL ,
long_desc text NOT NULL ,
min_beli int( 5 ) ,
jml_qty int( 10 ) ,
berat double( 7 )
);
CREATE TABLE IF NOT EXISTS harga(
id_produk varchar(10) NOT NULL,
tgl_aktif date NOT NULL,
tgl_deaktif date,
nominal_harga double(10)
);
CREATE TABLE IF NOT EXISTS testimonials(
id_testimoni varchar(10),
id_produk varchar(10),
id_user varchar(10),
isi_konten text,
tgl_buat date,
tgl_modifikasi date
);
CREATE TABLE IF NOT EXISTS order(
id_order varchar(10) NOT NULL PRIMARY KEY,
id_user varchar(10) NOT NULL,
tgl_order date,
total_bayar double(15),
jml_item int(10)
);
CREATE TABLE IF NOT EXISTS order_detil(
id_order varchar(10) NOT NULL,
id_produk varchar(10) NOT NULL,
harga double(15) NOT NULL,
qty int(10)
);
You have to provide the amount of decimal places for double, e. g. double (7, 2 ) means your number has a total of 7 digits, whereof 2 are decimal places, just like 10233,95
btw I would strongly recommend to get attuned to use english column names.. there will be one day people who need to understand your DB scheme and do not speak your language
You need to provide decimal places for the double. For eg: berat double( 7 ,2) will work fine
Check out the syntax for declaring columns with double datatype.
you have to indicate the length of the whole number and the length of decimal part
nominal_harga double(10,10)
read more here
Related
got this error message "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 'INSERT INTO 'employees1'"
Write your MySQL query statement below
create table employees1 (emp_id INT(6) UNSIGNED, event_day DATE NOT NULL, in_time int NOT NULL,
out_time int NOT NULL )
INSERT INTO 'employees1' ('emp_id', 'event_day', 'in_time', 'out_time')
values (1,20201128,4,32),
(1,20201128,55,200)
Please use a semicolon at the end of a statement, and use backticks for table names and column names. Those are fundamental rules which can be easily learned should you decide to spend a little more efforts.
create table employees1 (emp_id INT(6) UNSIGNED, event_day DATE NOT NULL, in_time int NOT NULL,
out_time int NOT NULL );
INSERT INTO `employees1` (`emp_id`, `event_day`, `in_time`, `out_time`)
values (1,20201128,4,32),
(1,20201128,55,200);
I am trying to create a table, but it gives me this error:
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 touse near ' INT NOT NULL AUTO_INCREMENT
Here is my code:
CREATE TABLE bowling_scores (
PlayerID, INT NOT NULL AUTO_INCREMENT
, LName VARCHAR(100) NOT NULL
, FName VARCHAR(100) NOT NULL
, Game1 INT NULL
, Game2 INT NULL
, Game3 INT NULL
, Game4 INT NULL
, PRIMARY KEY (PlayerID)
);
Here's a tip about syntax error messages: the message tells you where the error is.
check the manual that corresponds to your MySQL server version for the right syntax to use near ' INT NOT NULL AUTO_INCREMENT
This is telling you that MySQL became confused because it wasn't expecting to see that text. This usually means you made a mistake at that point, or immediately before it.
This can help you narrow down your search in the SQL statement to the point where it went wrong.
The error message also tells you what to do: check the manual. You should help yourself become better at SQL by reading documentation and examples.
I've been using MySQL for nearly 20 years, but I still refer to the reference docs every day. In fact, it's because I am experienced with MySQL that I know this is the right thing to do.
All SQL statements have a reference page in the manual. Here's the page for CREATE TABLE: https://dev.mysql.com/doc/refman/5.7/en/create-table.html
The MySQL manual is large, so it's easy to think "I don't know where the right page is." Gradually you can learn how the manual is organized. Pay attention to the hierarchy of links on the left column. When in doubt, just use Google for phrases like "mysql create table syntax".
You should be able to answer simple syntax errors for yourself instead of posting to Stack Overflow. You'll get your answer more quickly!
This is an obvious error:
PlayerID, INT NOT NULL AUTO_INCREMENT
You have an extraneous comma. It should be:
PlayerID INT NOT NULL AUTO_INCREMENT
Stop putting commas on the next line of your SQL statements as well!
This should work. You had a comma after PlayerID
CREATE TABLE bowling_scores (
PlayerID INT NOT NULL AUTO_INCREMENT,
LName VARCHAR(100) NOT NULL,
FName VARCHAR(100) NOT NULL,
Game1 INT NULL,
Game2 INT NULL,
Game3 INT NULL,
Game4 INT NULL,
PRIMARY KEY (PlayerID)
);
You should be writing something like:
creat table Bowling_score(Playerid int, Firstname varchar(100), Lastname varchar(100), Game1 int, Game2 int, Game3 int);
I am getting a SQL query syntax error while creating a table. Here is the SQL query:
CREATE TABLE ACCOUNT (
ACCNO NUMBER(5) NOT NULL,
NAME VARCHAR(20) NOT NULL,
BA L NUMBER(8,2) NOT NULL,
CREATION-DT DATE NOT NULL,
PRIMARY KEY ( ACCNO )
);
Here is the 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 'NUMBER(5) NOT NULL.
What is wrong with my syntax?
Using SQLfiddle you can see this is not valid.
You have multiple problems with your syntax; invalid data types, invalid column names, etc. You can encapsulate the invalid names in backticks but then you will have to remember to encapsulate them later.
Instead of Number you probably meant numeric but i would suggest trying Integer instead.
Or just try this:
CREATE TABLE ACCOUNT (
ACCNO INTEGER(5) NOT NULL,
NAME VARCHAR(20) NOT NULL,
BAL INTEGER(8) NOT NULL,
CREATIONDT DATE NOT NULL,
PRIMARY KEY ( ACCNO )
);
NUMBER is not a valid datatype in MySQL, you should choose the one from the list (maybe you've meant NUMERIC).
You should also escape some identifiers (in your case, column names BA L, which includes a space within it, and CREATION-DT, which includes a dash) with backticks ` in MySQL:
CREATE TABLE `ACCOUNT` (
`ACCNO` NUMERIC(5) NOT NULL,
`NAME` VARCHAR(20) NOT NULL,
`BA L` NUMERIC(8,2) NOT NULL,
`CREATION-DT` DATE NOT NULL,
PRIMARY KEY ( `ACCNO` )
);
SQLFiddle
CREATE TABLE 1
(text longtext(4,294,967,295),
date VARCHAR(50),
time VARCHAR(50),
id INT(11 ) NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY ( `id` )
What is wrong with the above SQL statement? I keep getting 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 '(4,294,967,295), date VARCHAR(50), time VARCHAR(50), id INT( 11 ) NOT NULL AU' at line 3
1 is a lousy name for a table. If you use it, you need to escape the name. Also, commas aren't allow in lengths for character fields and longtext doesn't need a length anyway:
CREATE TABLE `1`
(text longtext,
date VARCHAR(50),
time VARCHAR(50),
id INT(11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY
)
And, you don't "add" a primary key. You just declare it.
I am having the following error when trying to execute the following code in phpMyAdmin. I am using WAMP Server with MySQL version 5.5.8 ::
The error is:
#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 'NUMERIC(6) not null, payee VARCHAR2(20) not null, amount DECIMAL(6,2) no' at line 3
the SQL is:
CREATE TABLE checks
(
check NUMERIC(6) not null,
payee VARCHAR2(20) not null,
amount DECIMAL(6,2) not null,
remarks VARCHAR2(20) not null
)
EDIT
I am also trying to execute this but it gives also error:
CREATE TABLE deposits
(
deposit NUMBER(8),
whopaid VARCHAR(25),
amount DECIMAL(6,2),
remarks VARCHAR(20)
)
You need to escape check with backticks since it is a reserved word. And in MySQL there is no varchar2 data type, just varchar.
CREATE TABLE checks
(
`check` NUMERIC(6) not null,
payee VARCHAR(20) not null,
amount DECIMAL(6,2) not null,
remarks VARCHAR(20) not null
)
Also replace NUMBER with NUMERIC in your 2nd create statement.
CREATE TABLE deposits
(
deposit NUMERIC(8),
whopaid VARCHAR(25),
amount DECIMAL(6,2),
remarks VARCHAR(20)
)
SQLFiddle example
See MySQL String data types and MySQL numeric data types
check is a reserved work, that's why you have this error
you need to put quotes around it
CHECK is a reserved keyword in mysql. If you choose a different name it should work fine.
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html